5

Trying to setup Firebase Cloud Messaging for the first time. In the guide for Web app, there is a section on monitoring registration token refresh with onTokenRefresh.

https://firebase.google.com/docs/cloud-messaging/js/client?authuser=0#access_the_registration_token

However, looking in reference documentation I see this method is deprecated.

https://firebase.google.com/docs/reference/js/firebase.messaging.Messaging?authuser=0#ontokenrefresh

enter image description here

What does it mean there is no need to handle token rotation? Is a token obtained with getToken permanent? It's not a standard JWT token, so I couldn't decrypt if there is some sort of expiration.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
FredyC
  • 3,999
  • 4
  • 30
  • 38
  • 1
    If you find the documentation confusing, I suggest using the "send feedback" button at the top docs pages to send a note to the team. Indeed, the deprecation notice doesn't seem to make sense, and I personally would expect to have to use onTokenRefresh to get device tokens that do actually change over time. – Doug Stevenson Sep 06 '20 at 16:49
  • Appreciate your comment. I did send feedback, but I don't suppose I will get my answer there. I guess I will keep using onTokenRefresh and hopefully, it won't just disappear one day. – FredyC Sep 06 '20 at 17:59
  • You need to use `onNewToken()` now Ref: https://stackoverflow.com/questions/51123197/firebaseinstanceidservice-is-deprecated – DV Singh Sep 10 '20 at 07:42
  • @DVSingh Well, that's for Android, but I don't see any mention of such a method for JavaScript SDK. It certainly doesn't seem like a good idea to use undocumented methods. – FredyC Sep 10 '20 at 15:27

0 Answers0