GCM registrationId: is it static?

188 views
Skip to first unread message

Keven Wang

unread,
Sep 17, 2014, 7:44:10 PM9/17/14
to gcm-for-chr...@googlegroups.com
Hi,


I'm trying to get GCM registrationId in my Chrome extension's background.js. Seems like the registrationId changes each time the chrome.gcm.register() function is called. Is the registrationId supposed to change each time?

If so, would registrationId be the same across Chrome-synced clients (laptops)? E.g. if I install extension A, and use it on both laptop 1 and laptop 2 (Chrome synced), would the GCM registrationId be the same for these two extension instances?

Keven Wang

unread,
Sep 17, 2014, 7:46:55 PM9/17/14
to gcm-for-chr...@googlegroups.com
The reason I ask is: what would be the best way to manage user's registrationIds, if it can change over time. 

My thinking is that, each time an extension loads, it will send its registrationId to my server. My server will add that registrationId to a set<String> for that user. Then, for each push notification, I will check the success status. If a registrationId's push failed, I will remove that registrationId. Is there a better way to handle this?

Keven Wang

unread,
Sep 17, 2014, 7:58:24 PM9/17/14
to gcm-for-chr...@googlegroups.com
Seems like it's not static. And it would make sense to assign one registrationId per user per app.

This stackoverflow question helped:

Filip Gorski

unread,
Sep 19, 2014, 4:11:13 PM9/19/14
to gcm-for-chr...@googlegroups.com
Hi, Keven,

Registration Id is not static. It will also differ from one Chrome instance to another. You could try grouping the registration IDs into a single notification key and then simply send a message to that notification key.

Filip

Keven Wang

unread,
Sep 19, 2014, 4:19:50 PM9/19/14
to gcm-for-chr...@googlegroups.com
thank you for the reply.

Would that cause a bloat of registrationIds, though? Since each time client regenerates a new registrationId, the old one becomes invalid. Is there a way to tell if a registrationId is invalid, and if so remove the old registrationId from the set of registrationIds?

Filip Gorski

unread,
Sep 19, 2014, 5:47:13 PM9/19/14
to gcm-for-chr...@googlegroups.com
Hi,

When you send a message from your server it sends back information success/failure and reason. Some Registration Id come out as unregistered already, some suggest being replaced with a newer ones.

Check out example responses section here: https://developer.android.com/google/gcm/http.html

Thanks.
Filip

Keven Wang

unread,
Sep 19, 2014, 7:09:07 PM9/19/14
to gcm-for-chr...@googlegroups.com
Great. thank you!
Reply all
Reply to author
Forward
0 new messages