Search code examples
androidandroid-6.0-marshmallowandroid-backup-service

Android MarshMallow auto backup - do i need to exclude device specific Info like GCM id now?


Here is some info on play service backup and restore for MarshMallow

As you can see BackupAgentHelper is now not necessary. There is no effort needed by the developer to backup apps, its a toggle in the users settings to turn it off and on. Now imagine i have a GCM registration ID already stored in sharedPreference and now user switches devices and does a auto backup. The old GCM id will be included in the restore and the new device will not register for GCM and thus will not be eligible for remote notifications.

So to my point, do i have to write a backup scheme xml file to exclude the gcm ID and if so how do i do it: by exclude xml i mean this attribute in application tag of manifest: android:fullBackupContent="@xml/mybackupscheme"


Solution

  • Yes, we need to exclude the GCM id. The Android documentation states that...

    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.

    You can see here for details on how to exclude.