Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will FCM Token change periodically like GCM registration ID?

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

like image 321
ltvie Avatar asked Jun 03 '16 10:06

ltvie


People also ask

Does firebase device token change?

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.

How long does FCM token last?

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.

How do I update my FCM 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.

Is FCM token unique?

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.


1 Answers

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.

like image 61
Diego Giorgini Avatar answered Oct 19 '22 17:10

Diego Giorgini