1

I have noticed one issue in dealing with GCM. If you un-install the app and install it again the GCM registration id is changed for that device. And previous registration id is still working. So in my database there are multiple registration ids which are referring to one device. So sending only one notification received multiple times on the device.

Please help me on this.

android_griezmann
  • 3,757
  • 4
  • 16
  • 43

3 Answers3

1

You can solve this issue, with the use of canonical_id which is part of the response of GCM when called for sending push messages. Canonical Id can be used to detect duplicate register ids and you can use to prevent the problem.

Also you can read more about it in the following links

1- How to get Canonical Id from GCM ?

2- How to resolve the GCM duplicate messages problem ?

Community
  • 1
  • 1
Farhad
  • 12,178
  • 5
  • 32
  • 60
0

You can delete previous GCM id stored in you database while inserting new GCM id for the same user or device if you can track the same user somehow for example by loginid.

kiran boghra
  • 3,662
  • 2
  • 18
  • 23
  • Yes we are maintaining the unique ids for the every users and we are also replacing the registration ids every time user log in to the application. But the issue is on one device there can be multiple users logged in and logged out. So this is not working right now. – android_griezmann Feb 20 '16 at 05:45
  • So you can remove old td when new user login, I think it should work. – kiran boghra Feb 20 '16 at 07:01
0

As mentioned in the guideline of GCM

Note that Google may periodically refresh the registration ID, so you should design your Android application with the understanding that the com.google.android.c2dm.intent.REGISTRATION intent may be called multiple times. Your Android application needs to be able to respond accordingly.

You can replace the old GCM in your database instead of keeping duplicate copies as multiple Registration Ids are the reason for multiple push notifications.

Zohair
  • 318
  • 5
  • 12