Question

My application when the user is logged in am getting device token from GCM and registering my Server , if the user is logged out am deleting device token from my server. when the user is logged in then only i need to receive notification. its working fine, but one test case am receiving duplicate notification like twice with same data.

testCase : `user is loged in without logging out if the user is uninstall the app or else clear the data again install the app logged in application that time when i push notification am receiving two notifications with same data. how to avoid this duplication.

Was it helpful?

Solution

If the user clears the data stored on the device, there is not much you can do in the client side. You could assign a random id go each device and store it in external storage, which doesn't get wiped when app is uninstalled or app data is cleared. Your app can recover that id whenever it doesn't find the id in its local storage. This Id can be sent with the registration id to the server, and help to identify and prevent the case where the same device has two registration ids in your server.

If you can't prevent this situation, you can still fix it after receiving canonical registration id from Google, which would prevent duplicate messages the next time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top