I register in GCM with GoogleCloudMessaging.getInstance(context); and save received token on device. Then send it to server and it\'s associated with user account. If I uni
Welcome to the marvelous world of duplicate messages from Google Cloud Messaging
. When this happens, the GCM
engine enables the Canonical IDs
to solve it. This might happen because you registered with several IDs for the same device, or because the GCM
server didn't get the unregister()
call when the app was uninstalled. Using canonical IDs will set your ID to be the last registration you've made.
As per the GCM reference
about this:
Canonical IDs
On the server side, as long as the application is behaving well, everything should work normally. However, if a bug in the application triggers multiple registrations for the same device, it can be hard to reconcile state and you might end up with duplicate messages.
GCM provides a facility called "canonical registration IDs" to easily recover from these situations. A canonical registration ID is defined to be the ID of the last registration requested by your application. This is the ID that the server should use when sending messages to the device.
If later on you try to send a message using a different registration ID, GCM will process the request as usual, but it will include the canonical registration ID in the registration_id field of the response. Make sure to replace the registration ID stored in your server with this canonical ID, as eventually the ID you're using will stop working.
More info here.
Also there is a practical case on how to procceed, it might be helpful: