当我们尝试使用FCM向用户发送推送通知时,大多数设备都在推送,但很少有用户设备有时收到消息,有时候没有。我正在使用php curl调用来轮询设备令牌1000套设备的集合。请在下面找到它的代码:
$icons="";
define("GOOGLE_API_KEY", "AIuasdasjkdjadkajsdkad999asdI");
define("GOOGLE_GCM_URL", "https://fcm.googleapis.com/fcm/send");
$fields = array(
'to' => $tokenArr ,
'priority' => "high",
'notification' => array("body" =>
$message,"icon"=>$icons),
'data' => array("message" =>$message),
);
$headers = array(
GOOGLE_GCM_URL,
'Content-Type: application/json',
'Authorization: key=' . GOOGLE_API_KEY
);
echo "<br>";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, GOOGLE_GCM_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));
可能是什么原因? 请提供宝贵的反馈意见。感谢。