从 GCM 发送多个通知
2022-08-30 15:45:57
我正在使用PHP一次在多个Android设备上发送通知。所有注册ID都是唯一的,以下是我正在发送的CURL请求。
$url='https://android.googleapis.com/gcm/send';
$headers = array(
'Authorization: key=' . ANDROID_KEY,
'Content-Type: application/json'
);
$registration_ids = [];//with multiple registration ids
$notification = array(
'registration_ids' => $registration_ids,
'data' => array('notification_id' => $data['notification_id'],
'title' => $data['title'],
'message' => $data['message'])
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($notification));
$res = curl_exec($ch);
调试多次后,我无法找到在同一设备上多次通知(超过10次)的任何原因。
有没有办法检查GCM收到的请求的日志。任何线索将不胜感激。