【发布时间】:2017-11-22 09:37:43
【问题描述】:
我正在尝试使用存储在我的服务器中的 php 脚本发送通知,我得到了 MismatchSenderId。
$to="device_id";
$title="MYAPP Push";
$message=" MYAPP Push Notification Message";
sendPush($to,$title,$message);
function sendPush($to,$title,$message){
// API access key from Google API's Console
// replace API
define( "API_ACCESS_KEY", "server_key_provided_by_firebase");
$registrationIds = array($to);
$msg = array(
'message' => $message,
'title' => $title,
'vibrate' => 1,
'sound' => 1
// you can also add images, additionalData
);
$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;
}
这是我运行 php 脚本时遇到的错误:
{"multicast_id":7804476702639319453,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
我已经检查了 stackoverflow 中的每一个问题,但无法解决。
我正在使用 firebase(火花计划)并使用 Phonegap 开发应用程序。我认为这与应用无关
有什么想法???
【问题讨论】:
标签: php firebase firebase-cloud-messaging phonegap