Do GCM registration id's expire?

I know that C2DM registrations expire, and you are supposed to periodically refresh the registration ID. Is this the case with GCM? by looking at the following code on the Android GCM guide (shown below), it seems like you only do it once and don't need to refresh, but I dont see that explicitly written anywhere, so I just wanted to check.

final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
  GCMRegistrar.register(this, SENDER_ID);
} else {
  Log.v(TAG, "Already registered");



I found the answer myself. You don't explicitly need to re-register all the time, just once according to the example in the docs.

Also, unlike previous versions of GCM and C2DM, Google itself does not refresh the registration itself now: once you have the registration id from the initial registration you are good to go, except for one case: you do still need to re-register when the user upgrades to a new version (this case is also handled in the example in the link above):

When an application is updated, it should invalidate its existing registration ID, as it is not guaranteed to work with the new version. Because there is no lifecycle method called when the application is updated, the best way to achieve this validation is by storing the current application version when a registration ID is stored.

I think that it is refreshed eventually, yes. From the official docs:

An existing registration ID may cease to be valid in a number of scenarios, including: If the application manually unregisters by issuing a intent. If the application is automatically unregistered, which can happen (but is not guaranteed) if the user uninstalls the application. If the registration ID expires. Google might decide to refresh registration IDs. For all these cases, you should remove this registration ID from the 3rd-party server and stop using it to send messages. Happens when error code is NotRegistered.

This could happen in a request to GCM from your 3rd-party server, which returns a json response with the error Unregistered Device.

Once this happen, it'll be up to you to refresh the corresponding id's.

Need Your Help

What's the difference between pub and mult in core.async? & a sample usecase?

clojure core.async

I've been using core.async for some time, but avoided pub and mult, since I can't really grasp a useful usecase from their documentation.