I have published apps in playstore that use GCM and I have a plan to migrate using FCM. everything information i needed have found, but i have one question that not find answer yet. my question is when token have been created, are token will be change periodically like GCM does?
thanks
To be specific,The registration token may change when: The app deletes Instance ID. The app is restored on a new device. The user uninstall/reinstall the app.
Ensuring registration token freshness To cover all cases, you should adopt a threshold for when you consider tokens stale; our recommendation is two months. Any token older than two months is likely to be an inactive device; an active device would have otherwise refreshed its token.
To get a new refreshed FCM token (forcefully), first you have to delete it and then request for FCM token again. It will always provide a new token after once deletion. So, in your case you can delete FCM token on logout and request it again on login. It will work.
When the time comes to send a message, the token is read from the datastore and a data payload is sent via FCM to the specific device with the token assigned. A messaging token is unique per device and application.
Similarly to how GCM works, the FCM token can change due to token-rotation.
You can intercept the token rotation implementing the callback: FirebaseInstanceId.onTokenRefresh()
https://firebase.google.com/docs/cloud-messaging/android/client#sample-register
Note: the token rotation is a rare-event. Don't expect to see it often.
But still, if you care about the token you should implement onTokenRefresh()
to be informed of changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With