android - GCM - Unclear on how app update works? -


I'm looking at GCM, I'm not sure what to do in case of an application update. The doctor says: "When an application is updated, it should invalidate its existing registration ID, because it is not guaranteed to work with the new version. The best way to achieve this recognition is to That is, when a registration ID is submitted, then the current application version is stored. Then when the app is launched then the stored value is compared to the current app version. If they do not match, then invalidate the stored data and start the registration process again. "

So how should it look? Something like this:

  increases the public class MyActivity activity {@Override Creates at Public Zero (...) {if (we are a new app version) {// Calling Register () ) Force-starts the process of getting a new // GCM token? GCMRegistrar.register (reference, SENDER_ID); SaveLastVersionUpdateCodeToDisk (); }}   

So we just need to make sure that we call the GCMRGRRR registrar () again, when we have a new app version?

Thank you

Yes, you should register again with GCMRegister and in your broadcast receiver Make sure to update your server with a new ID.

Comments