Jacksonkr
Jacksonkr

Reputation: 32207

Android GCM send and MismatchSenderId

The odd thing is that notifications were working before. So I'm not sure what happened. I tried reinstalling my app to the device, but nothing changed.

{"multicast_id":xxxxxxxxxxxxxxxxxxx,"success":0,"failure":1,"canonical_ids":0,"results":[{"error":"MismatchSenderId"}]}

Because this was working at one point, I know I am using the correct keys. I even triple checked based on other SOF threads I came across. What could be the potential problem now? I've looked around for a few days now and I'm still at a loss..

** EDIT **

Here's the POST info when a message is sent out from my server.

Headers

Array
(
    [0] => Authorization: key=xxxxxxx-key-for-browser-apps-from-google-apis-console-xxxxxxx
    [1] => Content-Type: application/json
)

Fields

Array
(
    [registration_ids] => Array
        (
            [0] => xxxxxxxxx-big-old-id-from-the-device-xxxxxxxx

    [data] => Array
        (
            [message] => hello
        )

)

Also

I am using the key associated with Key for browser apps (with referers).

Upvotes: 1

Views: 15864

Answers (4)

Raj Kumar
Raj Kumar

Reputation: 796

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

Upvotes: 1

Raj Chauhan
Raj Chauhan

Reputation: 7

you did not use right device token, that's why you got the error. So, please get the new device token (Android mobile's token) and use it

Upvotes: 1

Jacksonkr
Jacksonkr

Reputation: 32207

Apparently, when you recompile your app it will sometimes throw off the device id generation to where it won't match a previous id.

What I have to do is a COMPLETE uninstall of the app on my phone and recompile the app again (via eclipse). This seems quite pathetic, but it's the closest to a workable solution I have at the moment..

Upvotes: 10

NickT
NickT

Reputation: 23873

I think it must be something to do with the way you have set up API access for your project in the Google APIs console, in particular the 'allowed referers'. As the dev docs say

Mismatched Sender A registration ID is tied to a certain group of senders. When an application registers for GCM usage, it must specify which senders are allowed to send messages. Make sure you're using one of those when trying to send messages to the device. If you switch to a different sender, the existing registration IDs won't work. Happens when error code is MismatchSenderId.

My project is set up to allow any referer like:

Key for browser apps (with referers) 
API key: my secret  
Referers: Any referer allowed

Perhaps you have restricted it to a certain IP range, and now you are trying to send the message from outside that range

Upvotes: 3

Related Questions