Google Cloud Messaging - Registration Identification Status

I am using the new GCM APIs to register. The method documentation clearly states:

Register the application for GCM and return the registration identifier. You must call it once when your application is installed, and send the returned registration ID to the server.

Repeated calls of this method return the original registration ID.

However, reading this article ( http://developer.android.com/google/gcm/adv.html#reg-state ), it says that there are two cases that require special treatment:

There are also two other scenarios that require special attention:

  • Application update
  • Backup & Restore

When the application is updated, it should cancel the existing registration identifier, since it is not guaranteed to work with the new version.

So, it is not clear when the developer should invalidate the registration identifier.

In addition, regarding the non-registration phase, the new GCM API states:

Unregister the application. The unregister () call stops any messages from the server. This is a blocking call - you should not call it from the user interface thread. You should rarely (if ever) use this method. This is not only an expensive resource, but also invalidates your registration identifier, which you should never change unnecessarily. The best approach is to simply stop sending messages to your server. Use only deregistration if you want to change the sender ID.

However, the previous same article said:

Whenever an application is registered, as described in the "Implementing GCM" section of the Client, it must save the registration identifier for future use, pass it to a third-party server to complete the registration, and monitor whether the server has been completed. If the server does not complete the registration, try again or unregister from GCM.

It is also not clear (for example, how to handle registration).

Finally, based on the foregoing, it is not clear how canonical identifiers are associated with a mobile phone. If Google issues a Canonical ID for an existing registration and transfers it back to the backend of the application, will it also change the registration ID of the mobile phone if it calls the registration method? Is there any other way for a mobile to get information about this new ID?

Thank you in advance!

+3
android push-notification google-cloud-messaging
source share
1 answer

Google assumes that your application must invalidate the registration identifier when the application starts after installing the new version. Their GCM demo application implements this offer. In addition to this case, there is no need to call the register method more than once (when the application starts for the first time).

Regarding deregistration, they suggest deregistering if you want to change your sender ID or if registration on your own server failed. The reason for the latter is that if your server has never received the registration ID from your application, it will never use this registration ID, and therefore there is no reason to register the application with GCM (if your application does not try again later to send the registration ID to your server).

Regarding the canonical registration identifier, the only way I know how to call the canonical registration identifier that should be returned to my server is to unregister the application from GCM (in order to invalidate the old registration identifier) ​​and then re-register to get a new identifier registration. In this case, if the server used the old registration identifier, it will work, but the new registration identifier will be returned as the canonical registration identifier. This is one of the main reasons why it is proposed not to cancel the registration unnecessarily (so as not to generate several registration identifiers for the same application on the same device).

Since the new registration identifier is created as a result of the actions that you perform on the client side (that is, unregister + register), your application should already be aware of the new registration identifier (yes, the register will return the last registration identifier, which is identical to the canonical registration identifier) , and your server should be notified of this and should not first send messages with the old registration identifier. Obtaining the canonical registration identifier in a response from Google covers only the case when your client could not transfer the new registration identifier to your server (or your old registration identifier could not be deleted on your server). Therefore, there is no need to inform the client about the new registration identifier.

Here you can read about changing the registration certificate and here about the canonical registration identifier.

+2
source share

All Articles