We have an app that uses GCM. When user firstly opens the app,app checks the shared preferences to look whether user is registered previously.if not the registration id is taken from GCM and stored to shared preferences. There is also a 3rd party server where user id and registration ids are stored. I read and implemented the following cases for canonical id issues:
- During sending notification,if a new registration id (canonical id) is received, the old registration id is updated with the canonical id in the 3rd party server.
- When user uninstalls the app, and when the 3rd party server sends a notification to uninstalled app registration id,not registered message is received and registration id is deleted from 3rd party database.
As a developer we have many registration ids stored in the database. Because we uninstall and install app frequently. Normally user will not do this. Then we considered using device id as a unique id for the device and check whether user registered previously. Is it ok to use android device id for this? What should i consider to prevent multiple registration ids for a device? These multiple registration ids cause multiple pushes to an Android device. The multiple registration ids mainly caused by:
- The app was uninstalled and reinstalled recently. How can i detect user uninstalled and installed and already have a registration id?
- The cache was cleared and/or the data was cleared for the app recently. How can i detect user cleared the app data and already hava an registration id?
What is the best practice for handling canonical ids?