0

Is it advised to backup GCM id using android cloud back up ? i am storing the GCM id in a sharedpreferences so i dont have to keep registering.

if i backup this GCM sharedpref and user changes devices do i need to update it to a new registration id ? Is the registration ID device specific ? What happens when user changes devices and backs up ?

I tried and read this from the docs:

You must exclude any device specific identifiers, either issued by a server or generated on the device. This includes the Google Cloud Messaging (GCM) registration token which, when restored to another device, can render your app on that device unable to receive GCM messages.

j2emanue
  • 60,549
  • 65
  • 286
  • 456
  • This is a design choice. You may want to store in the 'SharedPreferences', in a file or in a SQLite database. It really depends on the application and what you are trying to accomplish with it. You may try to view this Stack overflow ticket: http://stackoverflow.com/questions/16838654/handling-registration-id-changes-in-google-cloud-messaging-on-android – Android Enthusiast Jan 23 '16 at 19:17

1 Answers1

0

From the docs i found my answer that the reason this should not be done is that it can intrefer in the apps intialization of gcm and it will not try to get the GCM id if its already restored from a new device that restored a old registration id.

Handle Google Cloud Messaging

For apps that use Google Cloud Messaging (GCM) for push notifications, backing up the registration token that Google Cloud Messaging registration returned can cause unexpected behavior in notifications for the restored app. This is because when a user installs your app on a new device, the app must query the GCM API for a new registration token. If the old registration is present, because the system had backed it up and restored it, the app doesn't seek the new token. To prevent this issue from arising, exclude the registration token from the set of backed-up files.

j2emanue
  • 60,549
  • 65
  • 286
  • 456