FCM 获取 MismatchSenderId [英] FCM getting MismatchSenderId
问题描述
我有一个使用 Google FCM 发送推送通知的应用程序.
I have an application that uses Google FCM for sending push notifications.
当我向一组用户发送推送通知时,我会收到其中一些用户的 MismatchSenderId
响应.尽管如此,所有用户都拥有完全相同的应用程序.一些用户如何获得成功响应而其他用户获得 MismatchSenderId?
When i send a push notification to a group of users, i get a response of MismatchSenderId
for some of them. Even though, all users have the exact same application. How can some of the users get a success response and others get a MismatchSenderId?
我进行了很多研究,并确保我添加了 FCM 需要的所有先决条件.
I have researched a lot and made sure I have added all prerequisites that FCM needs.
有什么建议吗?
示例响应:
{"multicast_id":5340432438815499122,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}
编辑 2:
这里是服务器端发送代码(PHP):
Here is the server side sending code (PHP):
$fields = array
(
'to' => $token,
'data' => $data
);
$headers = array
(
'Authorization: key=AIza**************************',
'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, true );
curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode($fields) );
curl_exec( $ch );
curl_close( $ch );
更新:
该问题似乎已通过 SDK 更新解决.我现在使用的是最新的 com.google.firebase:firebase-messaging:9.6.1
,我不再收到MismatchSenderId"了.
It seems that the issue has been resolved with the SDK updates. I am using now the latest com.google.firebase:firebase-messaging:9.6.1
, I don't get "MismatchSenderId" anymore.
推荐答案
Firebase 已将其服务器密钥升级到新版本.使用新密钥而不是旧密钥.
Firebase has upgraded their server keys to new version. Use new keys instead of old one.
进入设置->项目设置->云消息标签
go to settings->project settings->cloud messaging tab
这篇关于FCM 获取 MismatchSenderId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!