RED_
RED_

Reputation: 3007

Push notifications failing because of invalid tokens being sent from GCM?

I noticed an issue in our backend that started happening in October. October 15th to be precise. It seems that I am getting invalid tokens from GCM on Android, which my backend is then storing and failing to send push notifications too.

One thing to note is that I'm using a deprecated api. Which may be part of the issue, but I have no way to confirm. This is the API I'm using to register users with GCM.

The tokens I'm getting back have a formatting that I'm not familiar with. This is what a valid token looks like for me, starts with APA9.

Valid token: APA91bFolo25yEfP2_3wUt3bPO08S3Hz1NBpJbyWkW5_hhsQ6WggOogQOXPYohmh

However I'm getting back tokens that look like this:

Invalid token: csPVRloDPzc%3AAPA91bFFU2DOGLg3hXoOvQ9vnhN3gMA4aalBAhGGJzAqt4Jtyy

Notice the extra characters at the start before the usual APA9. If I remove these extra characters, the token is still invalid. So I'm unsure what the exact issue is. The issue is happening very randomly, sometimes I get the correct tokens, sometimes I don't.

Obviously using a deprecated API is not ideal at all, and that will be the first thing I change, however this problem started on it's own, without any code changes, around the date I mentioned.

Any insight would be very helpful. Thanks.

Upvotes: 0

Views: 496

Answers (1)

Tim
Tim

Reputation: 43334

This is what a valid token looks like for me, starts with APA9.

A token does not have to start with APA9 to be valid. In my database I have IDs starting with just about any letter (but never a number).

One thing all my IDs have in common though, is a : as the 12th character, and APA9 right after that.

Your 'invalid' token that looks like csPVRloDPzc%3AAPA91bFFU2DOGLg3hXoOvQ9vnhN3gMA4aalBAhGGJzAqt4Jtyy also has one as the 12th character, but it appears to be URL encoded as %3A.

I suspect that if you decode that, it will suddenly be a valid ID.

Upvotes: 1

Related Questions