Php 正在从服务器获取响应,但未在设备上接收FCM推送通知
以下是向Php 正在从服务器获取响应,但未在设备上接收FCM推送通知,php,android,firebase,firebase-cloud-messaging,Php,Android,Firebase,Firebase Cloud Messaging,以下是向https://fcm.googleapis.com/fcm/send: {"multicast_id":5611071026900823002,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1492463891506691%01d24181f9fd7ecd"}]} 但我的Android设备无法接收任何通知 以下是我的PHP代码: private function sendPushNotifi
https://fcm.googleapis.com/fcm/send
:
{"multicast_id":5611071026900823002,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1492463891506691%01d24181f9fd7ecd"}]}
但我的Android设备无法接收任何通知
以下是我的PHP代码:
private function sendPushNotification($fields) {
//firebase server url to send the curl request
$url = 'https://fcm.googleapis.com/fcm/send';
//building headers for the request
$headers = array(
'Authorization: key=********' ,
'Content-Type: application/json'
);
//Initializing curl to open a connection
$ch = curl_init();
//Setting the curl url
curl_setopt($ch, CURLOPT_URL, $url);
//setting the method as post
curl_setopt($ch, CURLOPT_POST, true);
//adding headers
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//disabling ssl support
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//adding the fields in json format
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
//finally executing the curl request
$result = curl_exec($ch);
if ($result === FALSE) {
die('Curl failed: ' . curl_error($ch));
}
//Now close the connection
curl_close($ch);
//and return the result
return $result;
}
}
请发布您的Android端代码以接收messages@ArslanAli你用过这个吗?我也有同样的问题。是的@tamak。。。。。。。。幸运的是,我解决了问题。您是如何解决的?我正在检查设备通知,但没有启动fcm服务。。