rocklobster
rocklobster

Reputation: 126

Is there a constant part in GCM's regId?

Can I use a part of the registration id in Google Cloud Messaging to recognize a device, if it sends a new registration id to the App-Server?

Upvotes: 0

Views: 46

Answers (1)

Rob Meeuwisse
Rob Meeuwisse

Reputation: 2937

I doubt there is something in a regId that you could use.

I expect that it is designed to be random so you cannot make inferences like that for security reasons. Also, if you did find something then Google isn't giving you any guarantees it will stay that way.

The recommended way is to get the regId and send it to your App Server with a userId. (Which you either generate or ask the user for account info.) The idea is that a user could have multiple devices, so you should support multiple regIds per userId.

If you truly need a deviceId then you can generate that yourself. At startup check if you already have a deviceId generated. If not, then generate a random Id and store it in SharePreferences. Basically this is a installId, as when the user uninstalls and reinstalls it will be changed.

Upvotes: 1

Related Questions