[英]Sending Push Notifications to IOS Devices with php
我正在使用IOS App,它将通过FCM发送推送通知,我已经在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'
的教程,我做了但仍然没用
最近,我在Firebase和APN上都进行了Push通知,因此我可以根据您的FCM响应说从PHP端成功发送的Push通知
所以我想您正在处理应用程序方面的一些错误思考
由于我是PHP开发人员,所以我不太了解ios development.so,可以共享一些链接可能会帮助您调试
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.