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条回答
Root(大扎)
2楼-- · 2019-02-01 16:45

I also getting the same error. i have copied the api_key and change into google_services.json. after that it workig for me

"api_key": [
        {
          "current_key": "********************"
        }
      ],

try this

查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-01 16:46

Hello i have noticed that when an device id is created in GCM you cannot send push messages through FCM using the new server key, you have to use the old API-key.

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-02-01 16:52

I had the same error while trying to send push notificaion. Get the updated google-services.json file and replaced with it. Worked for me.

查看更多
迷人小祖宗
5楼-- · 2019-02-01 16:53

Updating firebase initialization works for me..

<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
 <script>
  // Initialize Firebase
  // TODO: Replace with your project's customized code snippet
  var config = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
    messagingSenderId: "<SENDER_ID>",
  };
  firebase.initializeApp(config);
</script>
查看更多
Deceive 欺骗
6楼-- · 2019-02-01 16:53

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.

查看更多
别忘想泡老子
7楼-- · 2019-02-01 16:55

As per response "MismatchSenderId", this is a mismatch between FireBase and your local "google-services.json", you have to make sure that both manifests matches

In FireBase console you go to "YourProject > Project OverView > Cloud Messaging" you'll see the "SenderID" which MUST match with the "google-services.json" in your Android project.

Best thing you can do is download the final json file from "General" tab and place it in your project.

查看更多
登录 后发表回答