Android GCM send and MismatchSenderId

后端 未结 4 1055
灰色年华
灰色年华 2021-01-23 08:46

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.

{\"multi         


        
相关标签:
4条回答
  • 2021-01-23 09:14

    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

    0 讨论(0)
  • 2021-01-23 09:28

    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

    0 讨论(0)
  • 2021-01-23 09:34

    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

    0 讨论(0)
  • 2021-01-23 09:37

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

    0 讨论(0)
提交回复
热议问题