Register a device on GCM every time the start of the application is the right approach?

I am developing a phonegap application and follow this guide for implementing PushPlugin. However, he says that register the application every time the deviceready event fires. This means that it will register the device with GCM, even if it was previously registered.

This made me a little uncomfortable, because it does not seem good practice, since the device is already registered, so I decided to come here to ask. Is this a good practice? If not, why? Does this have any long-term complication?

+7
android push-notification cordova google-cloud-messaging
source share
3 answers

In our application, we found this to be good practice for several reasons:

  • The device registration API returns the token that represents the device. From what I could see, GCM does not guarantee that the token will remain valid indefinitely. Thus, the inability to register can lead to the expiration of your device token.

  • Registering with GCM lets the service know that your device is active. From what we observed, devices recently registered with GCM turned out to receive push notifications the fastest. That is, given the 2 devices recently registered (device A) and the other one registered a few days ago (device B), device A will always receive push notifications faster - often several minutes before device B. This is just what we observed .

+7
source share

At Google, the official GCM Client demo application, they are registered with GCM only if a new version of the application is installed on the device. Therefore, I guess the best practice.

However, registering every time the application starts, your server receives a registration identifier, even if it somehow lost it, but this should not be a problem if your registration identifiers are stored properly on the server.

+5
source share

The problem with GCM is that it does not last forever, but time is not your biggest limitation. If you do not want to log every time there are several events that you must observe, this will invalidate the token, some of which are:

  • Every time the application is updated
  • When the phone reboots
  • A few days without notifications (not so sure, but it seems to be true in my case)

My advice: Register as often as you want, if this is a problem, how do you fix it. I would say that tracking a token to make sure it is still valid is too much work.

+1
source share

All Articles