Google Cloud Messaging - Registration ID Status
Solution 1:
Google suggest that your app should invalidate the registration ID when the app is launched after a new version is installed. Their GCM demo app implements this suggestion. Other than this case, there is no need to call the register method more than once (when the app is first launched).
As for unregistering - they suggest to unregister if your wish to change your sender ID, or if the registration in your own server failed. The reason for the latter is that if your server never got the registration ID from your app, it will never use that registration ID, and therefore there is no reason for the app to be registered to GCM (unless your app is going to retry later to send the registration ID to your server).
As for canonical registration ID, the only way I know how to cause a canonical registration ID to be returned to my server is by unregistering the app from GCM (to invalidate the old registration ID) and then re-registering to get a new registration ID. In that scenario, if the server used the old registration ID, it will work, but the new registration ID will be returned as canonical registration ID. That's one of the main reasons for the suggestion not to unregister unnecessarily (to avoid generating multiple registration IDs for the same app on the same device).
Since the new registration ID is created as a result of actions you take in the client side (i.e. unregister + register), your app should already be aware of the new registration ID (yes, register will return the latest registration ID, which is identical to the canonical registration ID), and your server should be notified of it and avoid sending messages with the old registration ID in the first place. Getting the canonical registration ID in the response from Google only covers the case in which your client failed to pass the new registration ID to your server (or your server failed to remove the old registration ID). Therefore the is no need to inform the client of the new registration ID.
You can read more here about handling registration ID changes and here about canonical registration ID.
Post a Comment for "Google Cloud Messaging - Registration ID Status"