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条回答
对你真心纯属浪费
2楼-- · 2019-02-01 16:39

Actually there are many reasons for this issue. Mine was because of Invalid token passed. I was passing same token generated from one app and using same token in another app. Once token updated , it work for me.

查看更多
戒情不戒烟
3楼-- · 2019-02-01 16:39

For me the problem was that I was using the phonegap-plugin-push in cordova, testing the app with the phonegap app.

The problem with this is that for some reason with this plugin, the phonegap app intercepts it and returns a dummy registration key, no matter what sender ID you have.

So to make it work (as long as you have all your keys right) is to test your program some other way, with an emulator, or android emulation via usb. And your keys will match.

Hopefully this saves someone some time.

查看更多
可以哭但决不认输i
4楼-- · 2019-02-01 16:39

your probably doing whwat i was doing. GCM token is not the same as FCM anymore. check if your pulling the GCM token ID instead of FCM. just override FirebaseInstanceIdService & ensure your getting the right ID. i thought at one point they were the same but now there not. i logged a test and saw. after you do that also update google-services.json like others say as a safety.

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

I had the same problem, and I fixed it like this:

  1. Go to your google fcm console
  2. Select your app
  3. In the left side menu find settings icon (standard wheel)
  4. Click on it and after click on project settings
  5. Now copy your server key and paste it in php

Voila...

查看更多
聊天终结者
6楼-- · 2019-02-01 16:41

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

查看更多
该账号已被封号
7楼-- · 2019-02-01 16:45

Make sure you remove all the Parse code from your app (libraries, receivers in AndroidManifest, etc). I found that intermittently push notifications were not working. From my observations, it would work on fresh installs but not app updates from the play store.

I believe something internal to Parse was conflicting with FCM (Parse uses GCM, so I'm guessing it had to do with using GCM and FCM simultaneously). As soon as I ripped out all the Parse receivers and libraries, things worked great.

查看更多
登录 后发表回答