FCM getting MismatchSenderId

2019-02-01 16:05发布

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.

19条回答
Explosion°爆炸
2楼-- · 2019-02-01 16:55

We spent hours and hours to resolve this issue. What we found that token was being generated using different FCM account settings (google-services.json) and notification was being set using different FCM account. When we synced both it worked like a charm.

查看更多
forever°为你锁心
3楼-- · 2019-02-01 16:59

what works for me :
I found that the senderId is different from the project number in the FCM console
so I re-downloaded google-services.json and everything works fine

查看更多
放我归山
4楼-- · 2019-02-01 17:01

I had the same problem. After hours spending to figure it out, I found this solution:

  • First I check server key is correct or not it was correct which is like AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  • Then I check Sender Id like 79XXXXXXXX it was also correct.
  • Main issue was in device_ID(UDID) to whom I have to send the notification. Actually DeviceId we got on android side in FCM is different than GCM. You can't use GCM created DeviceId in FCM.

Hope this will help you. Thanks

查看更多
再贱就再见
5楼-- · 2019-02-01 17:02

You will have a server key something like this AIzaSyDiTEVq4Li1pj7IyraRlyRU9adc-49-KVY available in the Settings section of firebase console console.firebase.google.com/project/project-XXXXXXXXXXXXX/settings/cloudmessaging.

Specify the correct key with your code and try again.

查看更多
疯言疯语
6楼-- · 2019-02-01 17:03

Firebase has upgraded their server keys to new version. Use new keys instead of old one.

go to settings->project settings->cloud messaging tab

enter image description here

Maybe it will work

查看更多
SAY GOODBYE
7楼-- · 2019-02-01 17:03

check gcm_sender_id in manifest.json If mismatch - correct, but you need make new subscribers for new sender Id. Exists subscribers break.

查看更多
登录 后发表回答