FCM getting MismatchSenderId

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.

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

enter image description here


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.

THIS WORKED FOR ME:

  • CHECK WHICH FIREBASE PROJECT YOUR CURRENT ANDROID PROJECT IS LINKED TO AND USE Server Key FROM THAT PROJECT.

I was using Server key from a different firebase project(say Project 2). I used the same server key as linked with my android project(Say Project 1) and it worked. In my experience, using one firebase app for one entire android project seemed to fix the problem.


Just an FYI. I was running into this error, even though I swear the android app I was testing was built with the latest/greatest google-services.json file and I could send from the FCM console to the app. I rebuilt the app after doing a Clean Project and now I can send to the app with the FCM token it registers. So, maybe try a clean rebuild before beating your head against the wall for too long.


In my case, I just was mistaking about project credentials: using google-services.json from one project, and server key from another.