I’m taking a look at GCM, I’m not sure what we need to do in the case of application update. The doc says:
“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. Then when the application is started, compare the stored value with the current application version. If they do not match, invalidate the stored data and start the registration process again.”
So what should that look like? Something like:
public class MyActivity extends Activity {
@Override
public void onCreate(...) {
if (we are a new app version) {
// calling register() force-starts the process of getting a new
// gcm token?
GCMRegistrar.register(context, SENDER_ID);
saveLastVersionUpdateCodeToDisk();
}
}
so we just need to make sure we call GCMRegistrar.register() again ourselves in case we’re a new app version?
Thanks
Yes, you should call GCMRegistrar.register again and in your broadcast receiver make sure to update your server with the new id.