I have an app published at the play store. When I want to send a notification, some users (for example, me) receive duplicate messages. I know that I have to handle it when I send the messages to recover the canonical ids and update the old registered id. But, Can I do something to fix this situation without sending any notification?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You should figure out a way to notify your server when GCM sends your app a new registration id.
Currently when you get a registration id from GCM, you send it to your server, which probably adds it to your DB without checking if that id should replace an old id.
In order to detect that case, and update the old id instead pf inserting a new one, you should assign your own unique id to each app instance, and send it to the server along with the reg id. You should persist that id in external storage, so that it survive even if your app is uninstalled and then installed again.