我正在开发和将通过FCM发送推送通知的IOS应用程序,我已经在FCM控制台上配置了所有内容并测试了从控制台向设备发送消息并且它有效。现在我使用下面的脚本,消息无法推送到手机。 当我发送时,我收到此消息
{"multicast_id":7893466200486146313,"success":1,"failure":0,"canonical_ids":0,"results":[{"message_id":"0:1506525095628728%b54fead7f9fd7ecd"}]}
以下是我的剧本
// Replace with the real server API key from Google APIs
$apiKey = "-------";
// Replace with the real client registration IDs
$registrationIDs = array('00000');
// Message to be sent
$message = "New Message from GWCL";
$url = 'https://fcm.googleapis.com/fcm/send';
$fields = array(
'registration_ids' => $registrationIDs,
'data' => array( 'message' => $message,'title' => "New Message",'notId'=>''.time(), 'complain_id'=>'90','push'=>'reply','priority'=>'high'),
);
$headers = array(
'Authorization: key=' . $apiKey,
'Content-Type: application/json'
);
// Open connection
$ch = curl_init();
// Set the URL, number of POST vars, POST data
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_POSTFIELDS, json_encode( $fields));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode( $fields));
$result = curl_exec($ch);
curl_close($ch);
echo $result;
我按照了一个教程告诉我添加'priority'=>'high'
,我做了但仍然没有工作
答案 0 :(得分:0)
最近我在Firebase和APN上都进行了推送通知,所以我可以根据您的FCM响应说出从PHP端发送成功的推送通知
所以我猜你在应用方面处理了一些错误的想法
由于我是PHP开发人员,我不太了解ios development.so可以共享一些可能有助于您调试的链接
firebase iOS not receive push notifications
Firebase when receive Push Notification did not receive the popup
iOS not receiving Firebase Push Notification sent through the API
Not receiving Push Notifications Using firebase and Objective C