1

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).

Charles
  • 50,943
  • 13
  • 104
  • 142
Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
  • Did you change anything in server side? – Adrián Rodríguez Dec 05 '12 at 16:17
  • I made some tweaks, but I posted the POST information leaving my server. It appears to check out, so I'm not sure what the deal is.. – Jacksonkr Dec 05 '12 at 16:37
  • 1
    As redIds may vary, are you sure you're using the last regId you obtain while registering? I had a similar problem a while ago, and the problem was that I was using an old regId inserted in my database. What I do now is: Register in GCM, saving regId in mobile (as a preference) and in a remote db. When the application is launched again, I register the mobile, checking if the regIds match; if they don't, I delete the old one from local and server and save and insert the new one in the mobile and in the database, respectively. If they match, I do nothing with it. Maybe it helps. – Adrián Rodríguez Dec 05 '12 at 16:48

4 Answers4

10

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..

Jacksonkr
  • 31,583
  • 39
  • 180
  • 284
  • 1
    Thanks man that helped me a lot. I guess Google is caching preferences which would explain why the uninstall helped. – Romain Piel Jul 10 '13 at 15:56
  • not worked http://stackoverflow.com/questions/35812304/pushnotification-not-working-properly – albert Mar 05 '16 at 10:21
3

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

NickT
  • 23,844
  • 11
  • 78
  • 121
  • 1
    Funny you should mention this. I actually HAD this problem earlier but figured out I had to use the default `Key for browser apps (with referers)` which fixed that problem. Great solution none-the-less. – Jacksonkr Dec 05 '12 at 16:53
  • 1
    In your API console does the section "Key for browser apps (with referers)" actually say "Any referer allowed"? If it does then I'm stumped as to what causes your error. – NickT Dec 05 '12 at 17:04
  • Great! Generated a `Browser key` and it worked! Strange why it is not working with server key. Would be nice to know ... – Paul T. Rawkeen Dec 26 '13 at 19:33
1

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

1

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