2

I am testing the updated google gsm cloud services with their sample app https://github.com/googlesamples/google-services/tree/master/android/gcm and I am following google tutorial here: https://developers.google.com/cloud-messaging/android/start

the device client is set up, I am receiving the token and I already have the google-services.json downloaded and configured on the my developer console.

I understand that the API key is used by the gcmsender module to send a test message, however I receive an error: "results":[{"error":"MismatchSenderId"}]} I have confirmed that the google-services.json is using the same sender id as was supplied to me by the developer console. What am I missing?

narkis
  • 335
  • 1
  • 7
  • 17

3 Answers3

4

Please run below script in your terminal

curl -X POST \
-H "Authorization: key= write here api_key" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [ "write here reg_id generated by gcm"], "data": { "message": "Manual push notification from Rajkumar" }, "priority": "high"
}' \ https://android.googleapis.com/gcm/send

MismatchSenderId because with in same device you have logged with different keys. to solve this problem uninstall app and run it againg and update the registration key. and then run the CURL script in your teminal which i post above it will give success message and you will get notification to your device

Raj Kumar
  • 688
  • 8
  • 18
  • Well - after all this effort - full uninstall of the test app was the answer. It seems Marshmallow is much more cache happy than previous versions. I did trace out the API key and sender Id before sending the message with gcmsender module. Both were tracing correct but apparently wrong info was actually delivered. Thanks Raj – narkis Feb 22 '16 at 15:07
0

Based on the Official Google Documentation. You will receive 'error:MismatchSenderId' when a registration token is tied to a certain group of senders. When a client app registers for GCM, it must specify which senders are allowed to send messages. You should use one of those sender IDs when sending messages to the client app. If you switch to a different sender, the existing registration tokens won't work. Check the Sender ID and API_KEY, API key is generated in Google Developer Console and used to authenticate/authorize with GCM and Sender ID is used by Android app to register a physical device with GCM to be able to receive notfications. Make sure that the API key belongs to 'Key for server apps'

Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
  • Your tip helped me to find a solution. I used a test Firebase project with test application (that contained right `google-services.json` file). Then I tried to send push notification to another application and got this error ('"error": "MismatchSenderId"'). I understood that the second application was bound to another Firebase project with different `google-services.json`. – CoolMind Aug 09 '19 at 15:18
0

If you use the cordova plugin phonegap-plugin-push then most likely you defined your sender id in the npm package.json like this:

{
  "id": "phonegap-plugin-push",
  "locator": "phonegap-plugin-push",
  "variables": {
    // TODO: this sender ID should probably be moved into a config file that can be inserted by a deploy script
    "SENDER_ID": "2342343443"
  }
},
"cordova-plugin-whitelist",
"cordova-plugin-console",
"cordova-plugin-device",
"cordova-plugin-splashscreen",
"ionic-plugin-keyboard",
"ionic-plugin-deploy"

...

The error happens when you don't set the sender ID or when you change the Google API Console Project in the backend and forget to update the frontend part of your application as well.

The Sender ID in the Google API Console is well hidden. Go here and scroll down towards a more recent answer: Android GCM SENDER_ID, how to get it?

In both locations, the sender ID needs to be identical. Don't forget to redeploy / reinstall your apps.

Community
  • 1
  • 1
Mario
  • 2,619
  • 1
  • 24
  • 22