我正在使用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接收到的请求日志?任何线索都将不胜感激。