New senderID does not work on GCM mismatchedSender

2019-08-03 19:29发布

问题:

A few months ago I activated my GCM from Google API console and implemented it in my Android project and all worked just fine. I was able to register, get the regId and send notifications from my server using my Server API key. All worked fine.

Yesterday I created a new senderID with my other gmail account, but when I replaced the senderID and server API key with the new information, Google replies the annoying mismatchedSenderID error message and the GCM won't be sent!

Nothing else has changed in the project, just a new senderID! What could be the problem?

回答1:

Well, if you started sending notifications with the new API Key, all the Registration IDs that were generated for the old senderID will stop working. You should clear your database and start collecting new Registration IDs (based on the new senderID) from your users.

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.