Repository navigation
fix: return cached token on iOS until APNs token is available - #33
Closed
qaysdwekat wants to merge 1 commit into
Closed
qaysdwekat wants to merge 1 commit into
qaysdwekat wants to merge 1 commit into
Conversation
getToken() called Messaging.token() before APNs delivered the device token, which fails with FCM error 505. Return the cached token (or null) instead; the new token arrives via onNewToken once APNs is ready. Fixes FAMEDLY-APP-A7T Refs: FM-968 Signed-off-by: Qays Dwekat <q.dweekat@famedly.com>
qaysdwekat
force-pushed
the
qais/FM-968-wait-for-apns-token
branch
from
October 29, 2026 08:08
3a3ce13 to
fe8e6ac
Compare
krille-chan
reviewed
Oct 29, 2026
| if Messaging.messaging().apnsToken == nil { | ||
| UIApplication.shared.registerForRemoteNotifications() | ||
| result(Messaging.messaging().fcmToken) | ||
| return |
Contributor
There was a problem hiding this comment.
This does not actually fix it. The bug is that if I await getToken() in dart, then I expect that it waits until the apns token is registered and then returns the fcm token. But this instead returns null and how should I then know that I have to wait for the other endpoint?
Member
|
moved to #38 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On iOS,
getToken()calledMessaging.token()before APNs delivered the device token, which fails with FCM error 505 (Sentry FAMEDLY-APP-A7T, mostly background launches).Now, while
apnsTokenis nil, it returns the cachedfcmToken(or null) and registers for remote notifications. Once APNs is ready, Firebase fetches the token and delivers it viaonNewToken, asgetToken()'s docs describe.Tested in the famedly app on an iOS simulator: normal init, plus a forced null on the first call, which takes the wait-for-onNewToken path.