bitsoverflow
bitsoverflow

Reputation: 606

How to use GCM Registration ID to send notifications

My team has been developing an app using GCM for the last 4 months, and today we discovered that with the recent update of Google Play Services GCM changed significantly. Until now we've been sending notifications from our backend server to our users using this format of Registration ID:

APA91bF7h6vQkqIaF9ECQ_V............w

That was generated with the classic GoogleCloudMessaging.getInstance(context).register(SENDER_ID) method.

But now, with the new update, you generate the registration ID doing InstanceID.getInstance(this)getToken(SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); and by doing so the generated Registration IDs have the next format:

c3wlROAji5d:APA91bF_iz3Muub6Mu...a6n-ClpQ

Notice how there is first a section of 11 characters followed by a colon and then a long sequence starting with APA91b

So my question is, when sending notifications from my server to my clients should I use the new format as it is or strip the fragment before the colon and use the segment starting with APA91b as before.

Thanks for the attention

Upvotes: 2

Views: 883

Answers (1)

ianhanniballake
ianhanniballake

Reputation: 199805

You should always use the full registration id to send messages to your users: it is best to think of the registration id as a totally opaque string (i.e., internal structure does not necessarily mean anything).

Upvotes: 4

Related Questions