-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Messaging getToken() always returns initialToken #1510
Comments
|
@britianoates If I read this correctly it would only impact the case where the token changed during a single app instance, correct? Like if you manually delete the firebaseId for example. Is that something you do when a user signs out? We are trying to chase down an issue on iOS where an FCMToken seems to stop working over the course of a couple days and I'm trying to determine if token refresh has anything to do with it. According to the Firebase docs a token refresh on it's own should be a rare event. |
We had many users not seeing the notifications we were sending. It was difficult to track down what percentage or when notifications stopped arriving. What you are seeing sounds similar to what we just dealt with in prod. To fix our users we've released a version of the app that calls RequestPermission every app opening to make sure the APNS and fcmToken remain synced. Calling to delete the firebase instanceId has been the only way we were able to recreate the failure to receive notifications. We do not delete the token as a part of normal app usage. |
Interesting. Does it seem like that fixed the issue for you guys? That sounds very similar to what we're seeing. We didn't notice this problem before our last release and in that release we added code to try and capture analytics events for how many users were denying notification permissions that had an early return if they had already enabled permissions. We also only request permission after a user signs in for the first time. Previously we had been calling requestPermission on every authenticated app opening. |
We have not been in production long enough to be confident our fix covers all use cases. It did cover all scenarios we were able to fake using deleteToken on a dev screen, and the one device from prod we had access to. Sounds like your solution was the opposite of ours. We only registered during the first run, and then the APNS and fcmToken seems to grow stale and we didn't have a mechanism to resync them. Our fix calls requestPermission on app start (Does not open modal, but does trigger a registration method. See my other ticket.) |
I'm seeing the same problem. Users that have been receiving notifications for weeks suddenly stop receiving them. I can have them open the app, get the token returned by firebase, put that token into the firebase console and send a message. The console reports success but the user never receives the push. It appears that somehow the token is invalid yet firebase doesn't see it as invalid. This is a very serious problem as we have no way of knowing which users simply never receive their push notifications. |
@jcharbo Are you also attempting to only call Firebase.requestPermissions() on a limited basis in your app? |
I have the same issue as britianoates. messenging().getToken() only returns the initialToken. It only happens on iOS. On Android, it works fine, when the token change, messaging().getToken() return the new token. |
This can be really easily reproduced. On iOS:
|
So, guys, what is the solution of the problem ? Just remove
as @britianoates noted above? Is it right ? |
Hello 👋, this issue has been automatically marked as stale because it has not had activity for quite some time. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions. |
Has anyone experimented with adjusting the implementation of Is this issue on the roadmap anytime soon? Is some more reproduction instructions or experimenting needed from the library users? |
How does the firebase.messaging().deleteToken() work? I'm getting the error of firebase.messaging().deleteToken() is unsupported by the native Firebase SDKs |
Can confirm that we're seeing this type of behaviour described above:
I'm checking that tokens are part of topics using this API call: https://iid.googleapis.com/iid/info/<FCM_TOKEN>?details=true&Authorizaton=<SERVER_KEY> And it seems they are, we're looking into the solution that @britianoates described
@smathson did you solve this issue? |
Any news on this? I am facing similar issue on iOS where a freshly retrieved FCM token is claimed to be not registered from FCM server when sending notification. |
@liokm Are you get this error only after removing token and getting new one ? |
@liokm this bug report was for |
@kholiavko-roman Actually my issue was a mix of two problems, one was that my app was transferred to another account and thus the team id and APNS key were invalid in FCM console and needed to be updated, otherwise "not registered" error is reported. Another problem is still waiting for feedback of logs. Have you tried to always requestPermission at start time anyway? |
@liokm Yes, I do |
@kholiavko-roman, how did you implement onTokenRefreshListener in you App? I did not find any API for this in react-native-firebase package. Thanks |
@lisichka999
|
I'm having the same issue here. firebase 5.4.0. platform: iOS |
I am having the same issue |
Leaving these references for anyone experiencing the same issue: |
What happened at the end??? |
It's been awhile. I ended up working around this by saving the token after an earlier call on my side rather than calling for it since this is broken. |
Would you please explain how you achieved what you're describing with some code. |
I found the solution.
Use this to delete the token then restart the app with |
It was enough for me to solve the problem (works on iOS & Android):
|
I'm going to reopen this as I think we have either a documentation issue or we need to alter the code to specify the asterisk as the default. Either way I appreciate the reports of what's working posted here, thanks |
v12.x.x coming up here will have this working correct on both platforms it seems - closing this as it will be backed by an automated test in our test suite. Use the scoped token workaround documented above until on v12+ Thanks! |
I'm using I call it with Also did another test, called The On Android, it works perfectly: a new token is generated, and also the previous one is invalidated (trying to send a message to it again from the REST API returns a NotRegisteredError). With the exact same JS code. |
And yet, there is an actual test I have verified (while fixing up the test, via console.log statements) appeared to work for me? This runs every commit react-native-firebase/packages/messaging/e2e/messaging.e2e.js Lines 109 to 118 in b8f80a4
|
@mikehardy I have a same issue like @rdsedmundo. When i call messaging().deleteToken() and then i continue call getToken() after, the new token and previous token are same. i use "@react-native-firebase/messaging": "^12.1.0". I have test on debug and production environment |
@milule can you confirm whether you were on simulator or real device? We think this actually may still be an issue from separate testing (contrary to my statement above, sorry) but only on real devices. We have not narrowed it down yet. |
Hello 👋, to help manage issues we automatically close stale issues.
|
We are getting the exact symptoms described above on Android, both simulator and real device. Both |
The failures on android are contrary to reported experience above, and my personal experience. When used properly (they are async, so you have to await...) it works fine on android we think. There still may a problem on iOS but as mentioned we have not narrowed it down. The best way to move this forward is to use either firebase-ios-sdk or firebase-android-sdk "quickstart" projects to reproduce this (or not) with the native SDKs so we may determine where the issue is. https://github.com/firebase/quickstart-android/tree/master/messaging They both are ready to go out of the box I think, or maybe need your google services plist/json files but otherwise ready for a quick reproduction |
This below snippet fixed my issue
|
Firebase-ios-sdk 8.6.0 included in react-native-firebase 12.7.0 should have another underlying fix for this so that deleteToken really works? |
Issue
messaging.getToken() keeps returning the first token, even if the firebaseId has been deleted and a new token generated.
To Reproduce. In a onTokenRefresh callback, log out the parameter token and a messaging.getToken and compare. No matter how many times you delete the instanceId generating new tokens you'll always receive the first token.
Environment
Both
mac High Sierra
xcode 9.4, Android Studio 28
React Native
version:"react-native": "0.55.4",
React Native Firebase
Version:"react-native-firebase": "^4.0.3",
Firebase
Module:firebase-core:12.0.1
firebase-analytics:12.0.1
firebase-messaging:12.0.1
typescript
?no
The text was updated successfully, but these errors were encountered: