1

GCM Notifications for the android app were perfectly working until the Server's which was used to send notification domain expired.

Upon domain renewal gcm notifications are not working. If I use current API Key, it gives

401 Unauthoried Acccess

On Generating new API key and new GCM id it gives below error

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

How can I fix this problem?

Dhaval Desai
  • 318
  • 4
  • 13
  • Is the new generated API key a "server key"? – Arthur Thompson Jul 04 '16 at 13:40
  • @ArthurThompson, Yes. – Dhaval Desai Jul 08 '16 at 05:50
  • The error MismatchSenderId usually indicates that the token you are sending to was not generated for the project that the API key belongs to. Is your new API key part of the same project as the previous one? – Arthur Thompson Jul 08 '16 at 16:12
  • @ArthurThompson, Yes, it is the same project, only the key is newly generated. Previously though it was Android Key, which worked from server. Now I have generated Server key which gives MisMatchSenderId. Android Key gives 401 Unauthorized Access error. – Dhaval Desai Jul 11 '16 at 13:54

1 Answers1

3

Based on Official Google Cloud Messaging documentation, 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.

Double check the Sender ID and API_KEY, they must match or else you will get that MismatchSenderId error. See the Stack Overflow post: Why do I get MismatchSenderId from GCM server side?. And for the 401 Unauthorized Acccess error means that your API key is not valid. The issue is only for the method of generating a notification key on Android devices using a Google auth token.

Community
  • 1
  • 1
Android Enthusiast
  • 4,826
  • 2
  • 15
  • 30
  • Thanks for your response. Sender Id has not changed. I have crossed checked it. I have generated new API_KEY and GCM reg id. But it doesn't work. Is there a chance that sender id gets changed since it is a same project. – Dhaval Desai Jul 04 '16 at 06:32
  • Hi @DhavalDesai , could you please confirm how your issue was resolved? Based on your comment, it seems that you did the right thing, and even then you faced the error from server. – garnet Apr 26 '18 at 07:51
  • @garnet, I was working two Apps at that point of time. The issue occurred because I was using the Project Number of first App to send Notification to Second App. Correcting the Project Number resolved the issue. – Dhaval Desai Apr 27 '18 at 11:13