【发布时间】:2018-05-05 17:58:33
【问题描述】:
我正在尝试使用 FCM 将通知从 php 推送到 IOS。 这是我的代码。
$serverKey = 'MYKEY';
define('API_ACCESS_KEY', $serverKey);
$registrationIds = ($vals['registration_ids']);
$msg=$vals['data'];
// prep the bundle
$fields = array
(
'registration_ids' => $registrationIds,
'data' => $msg
);
$headers = array
(
'Authorization: key=' . API_ACCESS_KEY,
'Content-Type: application/json'
);
$ch = curl_init();
curl_setopt( $ch,CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send' );
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 );
curl_close( $ch );
echo $result;
但它总是说:
{"multicast_id":9213457463518601541,"success":0,"failure":7,"canonical_ids":0,"results":[{"error":"NotRegistered"},{"error":"NotRegistered "},{"error":"NotRegistered"},{"error":"NotRegistered"},{"error":"InvalidRegistration"},{"error":"InvalidRegistration"},{"error":"NotRegistered "}]}
【问题讨论】:
-
这意味着您的代码运行良好,但是应该接收消息的手机在其应用程序中没有正确的 SENDER ID。请让他们更正。
-
他们有 SENDER ID。但是我如何检查 SENDER ID 是否正确?感谢您的回复。
-
您不能检查,如果 SENDER ID 与您或您的团队从 FCM 控制台提供的内容匹配,请让他们检查 logcat
标签: php web-services codeigniter