Registration ID duplication for GCM

北城余情 提交于 2019-12-05 08:04:09

To handle the situation of a user uninstalling and re-installing the app (or clearing the app data), I'd store the user id (or whatever identifier you use to identify an application instance on a specific device) in the external storage of the device. This storage won't get wiped when user uninstalls the app or clears the app data (it can still be deleted manually by the user, but there's nothing you can do about that).

Then, when you launch the app, if user data is not available in shared preferences, you attempt to restore it from the external storage. Only if it's not available in the external storage, you assume this is a new installation of the app on a new device and register to GCM (in addition, you are also advised to re-register to GCM whenever a new version of your app is installed).

And if all this handling at the client side fails, you still get a chance to remove duplicate registration IDs from the server, whenever you get a canonical registration ID in the response from Google.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!