Reputation: 83
I am working with android app in which i am using GCM. now I don't know when to create new Registration Id for device.? I am saving Registration Id in sharedpreferences. and i know that when app version changes we have to regenerate ID. but when user logout from app, does it necessary to regenerate ID ? Can I use previous Reg Id for that particular user because I am storing it in database. can multiple devices have same Registration IDs?
Upvotes: 0
Views: 277
Reputation: 8032
Get the device ID on following cases.
Upvotes: 1
Reputation: 2515
You should regenerate the registration id on phone reboots, app updates and OS updates. Check this blog post.
Upvotes: 1
Reputation: 1570
Hope I'm not intruding on what @iRuth is planning to advise. Here are some things I want to point out:
data
field in your message to specify the intended user/recipient. Multiple devices cannot have the same registration IDs. gcm.register()
call. Lastly, I am assuming that by database you meant the client device's database. In that case, yes, just use the already existing registration ID. If you meant your server's database, you will always need to maintain a record on your device of the registration ID and its associated app version. Only having it on your server's DB is not advisable as your client device may no longer be reachable via GCM if the app has been updated.
Upvotes: 0