0

I know that the registrationID of my device is not stable in GCM and it might be expired on google server.

When registrationID is expired I should renew it and send it to my GCM server.

My Android app saves its first registrationID and use it. How can I notice in my Android app if registrationID has been expired in google server for renewing it and sending to GCM server?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Bob
  • 22,810
  • 38
  • 143
  • 225

2 Answers2

1

According to the docs

Google may periodically refresh the registration ID, so you should design your Android application with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times. Your Android application needs to be able to respond accordingly.

Also Note:

The registration ID lasts until the Android application explicitly unregisters itself, or until Google refreshes the registration ID for your Android application.

So you need to update the registration ID on your server when you recieve the com.google.android.c2dm.intent.REGISTRATION intent.

Also you can have a code in your launcher/main activity that checks whether you are registered on GCM as follows

String regid = getRegistrationId(context);
if (regid.length() == 0) {
    registerBackground();
}
Blumer
  • 5,005
  • 2
  • 33
  • 47
Sunil Mishra
  • 3,796
  • 1
  • 27
  • 40
-1

There is no such function or API available to check for it, you need to define the a certain period of time for periodically refreshing it inside the client.

strike
  • 1,031
  • 8
  • 24