Skip to content

fix(ios): wait for the APNs token in getToken - #38

Merged
td-famedly merged 2 commits into
mainfrom
td/ios-gettoken-wait-for-apns
Nov 21, 2026
Merged

td-famedly merged 2 commits into
mainfrom
td/ios-gettoken-wait-for-apns

Conversation

@td-famedly

Copy link
Copy Markdown
Member

On iOS getToken() called Messaging.token() before APNs had delivered the device token, which fails with FCM error 505 "No APNS token before fetching FCM Token". That is ~9.8k events in 90 days in the Famedly app (Sentry FAMEDLY-APP-A7T, FAMEDLY-APP-AEQ), mostly right after app start.

getToken() now waits instead: while apnsToken is nil it registers for remote notifications and answers once APNs delivers the token, or with the registration error. The token is also handed to Messaging explicitly, so this works with Firebase swizzling disabled.

Follows the review on #33: awaiting getToken() should wait for APNs and return the FCM token, not null. Bumps to 4.0.1.

Refs FM-968

Draft until it has been built and cold-started once on iOS; CI only runs the Dart checks.

Signed-off-by: td <j.nirve@famedly.com>
Signed-off-by: td <j.nirve@famedly.com>
@td-famedly
td-famedly marked this pull request as ready for review November 15, 2026 19:54
@td-famedly
td-famedly requested a review from a team as a code owner November 15, 2026 19:54
@td-famedly
td-famedly merged commit cc854fd into main Nov 21, 2026
6 checks passed
@td-famedly
td-famedly deleted the td/ios-gettoken-wait-for-apns branch November 21, 2026 17:05

This branch was successfully deployed

1 active deployment
pub.dev — fac2376a Deployed Nov 21, 2026 by td-famedly via call_publish / publish #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants