New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 [firebase_messaging] .onTokenRefresh not called even when it actually got refreshed #10209
Comments
Thanks for the report @Shawn-sudo
There's no code changes or updates related to token recently, so if you are seeing this behavior intermittently, then it could be a server or native side issue. |
It happens occasionally: not necessarily after the first install. I have no clue how long it would take to reproduce this issue. It sometimes take a week, sometime take an hour. I'm quite sure that mine should be working well, but just in case. Seeing this source code here, I'm guessing that By the way, one thing to mention, the fcm token for my phone changes at least once in a day. This StackOverflow Answer says that key rotation is such a rare event, so I think something else is going wrong on my app, too. I'm trying the plugin example rn. I'll come back when I find the issue |
Thanks for the update.
Maybe not from the backend, but one of the ways is to delete the fcm token and then request for it again which will provide a new token. |
@darshankawar Oh thanks |
Ideally it should be called. So, if you are deleting the token like below and then call
And then:
where |
@darshankawar One thing I noticed, when I run the app on my phone using Flutter release mode through Xcode, it seems to disable receiving the notifications. Probably I was confused with that. Thanks! |
Bug report
FirebaseMessaging.instance.onTokenRefresh.listen((newToken) {...})
is not called even in the expected situation (app running on the foreground, internet connected, foreground notification implemented, Firebase Messaging backend starting to throw "Requested entity was not found" error)As a result, users (me) suddenly became unavailable to receive notifications while using the app.
Once I quit the app and relaunch it, the regenerated token is well updated by calling
FirebaseMessaging.instance.getToken()
Until I relaunch the app, the backend throws "Requested entity was not found" error and I become unavailable to receive notification
Check this video for more info: https://vimeo.com/785835642
Steps to reproduce
(It's gonna be a bit tricky, cause the app should be opened when the token is regenerated)
(I found this bug on iOS. I'm not sure if this also happens on other platforms)
.getToken()
and update itFirebaseMessaging.instance.onTokenRefresh
properly by.listen()
ing to it.onTokenRefresh
hasn't been called. When I relaunch the app,.getToken()
gives me a different token from the one that was previously registered.Expected behavior
.onTokenRefresh
should be called when the token is regeneratedAdditional context
Nope
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
The text was updated successfully, but these errors were encountered: