Is it expected that InstanceId change on app force stopped?

1.5k Views Asked by At

I am trying out Play Services GCM 7.5. However, it looks nice to have InstanceID class. However, the instance ID string changes every time I swipe the app out of Recent tasks, or force stop the app. It doesn't change if the activity is finish(). Is it expected behavior? Shall the instance ID be persisted the first we get it?

Below is the codes to get GCM token and instance id:

            InstanceID instanceID = InstanceID.getInstance(this);
            String token = instanceID.getToken(getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE);
            Log.e("FOO", getClass().getSimpleName() + ": " + instanceID.getId() + " | " + token);
            sendPushRegistrationTokenToServer(token);

Below is the codes to read the instance ID later:

            InstanceID instanceID = InstanceID.getInstance(this)
            tokenTextView.setText(instanceID.getId());
1

There are 1 best solutions below

0
On

To fix this update your GCM, I can confirm that GCM 7.8 works fine.