user3935018
user3935018

Reputation: 177

Updating GCM registration ID after device update

In order to get an updated registration ID once a user upgrades their android version, do I need to first unregister the original registration ID by calling unRegister before I get the new registration ID?

Upvotes: 1

Views: 652

Answers (4)

Sash_KP
Sash_KP

Reputation: 5591

@Eran is absolutely right.Upgrading your android version won't change gcm registration id.However sometimes may be because of some bug in your app or uninstalling(and again reinstalling the app) gcm may change your registration id.But thankfully gcm provides the concept of canonical ids.So i don't think you will need to unregister your device from gcm for this case but you need to deal with the canonical id properly if it occurs.

Please refer here and have a read about canonical ids

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.

Upvotes: 0

Damian Petla
Damian Petla

Reputation: 9113

Updating registration ID is not required if Android device get updated with newer Android version e.g. JellyBean to KitKat.

You have to update registration ID if your application is updated. In that case you don't have to un-register at all, just register again and clear stored previous ID in the local storage.

Android Developer page has well written chapter about GCM Advanced Topics. You should be interested in Unregistration and Keeping the Registration State in Sync

Upvotes: 0

Saba Jamalian
Saba Jamalian

Reputation: 760

You don't have to do that and if you do the registration ID will remain the same.

If you want to have a completely new and different registration-id you need to register with another project-id. Also, if you change your package name for your project, the registration-id would change too.

Upvotes: 0

Eran
Eran

Reputation: 394156

You don't have to un-register before registering again to GCM, unless you are changing the sender ID (project number) used to register. In fact, the registration ID may even stay the same if you register with the same sender ID.

Upvotes: 1

Related Questions