当我尝试发送多次推送通知时,我得到的错误就像。
我的PHP编码是: -
<?php
//Sending Push Notification
function send_push_notification($device_id, $msg)
{
//echo "fdff";
// Set POST variables
$url = 'https://android.googleapis.com/gcm/send';
//$message1 = array("header" => $msg);
$x = array($device_id);
$fields = array(
'registration_ids' => $x,
'data' => array("message" => $msg),
);
//print_r($fields);
$headers = array(
'Authorization: key=' . "AIzaSyAYmZljXmJWgIqD5sQ9_0d- jUVorm3ZnhA",
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
curl_close($ch);
return $result;
}
?>
这是我的错误。
{"multicast_id":5911003352460212858,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
{"multicast_id":5737426372728217758,"success":1,"failure":0,"canonical_ids":1,"results":[{"registration_id":"APA91bHa4mmnj2EZfiN7EVa5c_eCVKBkQJmImpfedThbwoxyzlxh3f_NGRJ8mVCp63JQnL8ZvKvtH6P_Nz5O_MKu1Kgy7d2oJhLt6-82xK499n1P_mTp6t4m11ERlaU6Oe6vEmqG6CBu","message_id":"0:1449254314294720%66e3e4c4f9fd7ecd"}]}
在这段代码中,我在两台设备上取得了成功,但在一台设备中却没有发送。 那怎么可能呢?