Describe the bug
onTokenRefresh being called every time the app loads even the tokens are the same
To Reproduce
_firebaseMessaging.onTokenRefresh.listen((token) => _saveToken(token)); // save token when it was refreshed
Expected behavior
only fire when token is refreshed
Additional context
firebase_messaging: ^6.0.3
Still not fixed.
Still not fixed.
You can workaround by storing token local and compare to ignore in case it is the same
Still not fixed.
You can workaround by storing token local and compare to ignore in case it is the same
Yeah, this is exactly what did it :) thanks!
Still not fixed.
You can workaround by storing token local and compare to ignore in case it is the same
However this is not the expected behavior we need the library fix.
Is there any upcoming fix? This is quite disappointing.
@xJon You can do workaround, something like this:
Stream<String> fcmStream = instance.onTokenRefresh.distinct();
fcmStream.listen((token) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String fcmToken = prefs.getString('fcm_token');
if (fcmToken == token) return;
// ...
// create new token below and save it in SharedPreferences
// ...
});
Most helpful comment
However this is not the expected behavior we need the library fix.