本文介绍了FCM获取MismatchSenderId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Google FCM发送推送通知的应用程序。

当我向一组用户发送推送通知时,我得到 MismatchSenderId 。尽管所有的用户都有完全相同的应用程序。一些用户如何获得成功响应,其他人得到一个MismatchSenderId?



我已经研究了很多,并确保我已经添加了FCM需要的所有先决条件。 p>

有什么建议?

编辑:


$ b

  {multicast_id:5340432438815499122,success:0,failure:1 ,canonical_ids:0,results:[{error:MismatchSenderId}]} 





以下是服务器端发送代码(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。

$ b $ Firebase已将其服务器密钥升级到新版本。
使用新键而不是旧键。



也许它会工作


I have an application that uses Google FCM for sending push notifications.

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?

I have researched a lot and made sure I have added all prerequisites that FCM needs.

Any suggestions?

EDIT:

Sample response:

{"multicast_id":5340432438815499122,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}

EDIT 2:

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 );

UPDATE:

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 has upgraded their server keys to new version.Use new keys instead of old one.

Maybe it will work

这篇关于FCM获取MismatchSenderId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 19:42