1

I have implemented GCM in my app and my device gets two alerts after reinstalling the app.I have read about canonical id's but it's really hard to find information on how to use it or how/where to implement it. Google's docs are very vague sometimes and don't provide examples. This is how I do a normal registration to get the regID.

GCMRegistrar.register(this, getString(R.string.gcm_project_id));

Do I change this code to send a canonical registration and if so how? My server is not telling me there are any canonical ids it always says success 3(should be 2 for other device) and canonical 0. So there is no way for me to update the DB as it doesn't let me know there is a dupe.

Panama Jack
  • 24,158
  • 10
  • 63
  • 95

2 Answers2

0

You are mixing stuff, this call accepts the sender id taken from the google api console. The registration id is sent to you though the onRegistered method inside the GCMBaseIntentService which you should send to the server so you can use it in the push notifications sending. Now if you have an old registration id then google will send to your server the updated registration id AKA Canonical id in the response of the sending service.

Mahdi Hijazi
  • 4,424
  • 3
  • 24
  • 29
  • 1
    I think I understand now, but it was a bit confusing. I wasn't getting notified that I have a duplicate because my server somehow registered the ID twice so it technically was the same ID just being used twice to send a message. So that's why the canonical ID said 0 in the response. Sometimes things aren't very clear for me I guess even though I read several SO questions. Thanks for the response. – Panama Jack Apr 23 '13 at 11:29
  • @Mahdi Hijazi not working for my case, i have sent message to both old app 'reg_id' and reinstalled app 'reg_id' but for old app GCM shows { error: 'NotRegistered' }, and 'canonical_ids: 0, still i am not getting canonical_ids can you please tell me why it is not working for me ?? – Sudhanshu Gaur Jul 28 '16 at 14:05
0

Everything is we need to update existing registration id with canonical id in server where we have stored. You ca use this answer Update Canonical Id

Community
  • 1
  • 1
Raghu
  • 31
  • 7