16

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

Mike Yang
  • 2,581
  • 3
  • 24
  • 27
ltvie
  • 931
  • 4
  • 19
  • 48

1 Answers1

24

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.

Diego Giorgini
  • 12,489
  • 1
  • 47
  • 50
  • sound good for me if token rotation is a rare event, so i not check everytime. we know the GCM was changed the gcmID every uninstall or update new version of apps. so we must check periodically gcmId was changed or not. in FCM we don't do it anymore right? – ltvie Jun 04 '16 at 00:20
  • 3
    It is the same process for both FCM and GCM, you implement a callback to handle the expiration of the token, and whenever that occurs your code in the callback will be executed. – Arthur Thompson Jun 04 '16 at 02:10
  • Arthur is correct. And ltvie is correct too that you don't need to check again after updates. – Diego Giorgini Jun 04 '16 at 02:13