1

I am new to Firebase Cloud Messaging. While I was developing and using single AVD to test, I noticed that the token changed.

There is a similar question, but it does not help when developing with Flutter.

How can I get the new token? Will the token change while the app is running or in between app stop and start?

In the other question's answer, it says:

As you pointed out the token can change, in which case the onTokenRefresh() method will be called again.

How will it happen in case of Flutter?

Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
  • it seems more complex with https://stackoverflow.com/questions/39157236/firebase-cloud-messaging-auth-tokens-vs-registration-token –  Mar 30 '20 at 03:27

1 Answers1

2

You can listen to it in Flutter. Use,

firebaseMessaging.onTokenRefresh.listen((token) => saveOrSendToken(token));
Peter Mortensen
  • 30,030
  • 21
  • 100
  • 124
Abhay Koradiya
  • 1,976
  • 1
  • 14
  • 35