I am using Google Cloud Messaging (GCM). Sending a push notification at my server, I got back a canonical id. Is it possible, that the canonical id I get back is (sometimes) the same like the current (or a new) registration id of the client (getting in android with GoogleCloudMessaging.getInstance.register)?
Asked
Active
Viewed 118 times
0
-
No, it's impossible. Why do you ask about it? Did you get cannonical id equals current regId? – Samik May 31 '15 at 07:38
-
I got a canonical id, which was not equal to the current regId. But AFTER getting the canonical id, I used GoogleCloudMessaging.getInstance.register again, and then I got a regId, which was equal to the canonical id... – user1711384 May 31 '15 at 11:26
1 Answers
1
You should call GoogleCloudMessaging.getInstance.register only ONE time, after your version code is changed (update is happened) or your application was restored after backup. Cannonical_id is a signal for your server, not for your client. You got same regId, because GoogleCloudMessaging put it in a cache, don't call regId many times. And when you got cannonical_id from gcm you should be sure that you replace old regId with new one.

Samik
- 890
- 1
- 8
- 16
-
I only call getInstance.register after app- or android-update and when the app data was deleted. Wha do you mean with cache? So there is still a connection between regID and canonicalID? – user1711384 Jun 06 '15 at 12:05
-
1I mean you don't need call register method many times, and places which you described are good for it. Yes, between regId and cannoncalD there is connection. If for some reasons (user quickly reinstall your app) and your push-server continue to use old regId then GCM will pass cannonicald parameter and report fresh registrationId to your push-server. For more information look at my answer about usage of canonicalIds http://stackoverflow.com/questions/26826869/regarding-canonical-ids-in-gcm-google-cloud-messaging/26827470#26827470 – Samik Jun 08 '15 at 17:11