[firebase_messaging]: Android getToken() errors lose their cause since firebase-messaging 25.1.0 ("FCM Registration failed!")
Maintainers usually reply within 4 days
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
Research direction
Start with the Android side of FirebaseMessaging.getToken() and the Dart error mapping that turns the native exception into firebase_messaging/unknown. Reproduce with the adb steps in the issue, then check how the underlying exception cause is dropped. Pull request #18999 is already open against this, so review it before starting. Done means the native failure reason, such as SERVICE_NOT_AVAILABLE, reaches Dart.
Written by the indexing model from the issue text.
Description
Is there an existing issue for this?
- I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
Since firebase_core 4.11.0 (Firebase Android BoM 34.15.0, firebase-messaging 25.1.0), when the token registration fails, getToken() on Android reaches Dart with the same text, whatever the reason:
[firebase_messaging/unknown] java.io.IOException: FCM Registration failed!
The underlying reason, such as SERVICE_NOT_AVAILABLE or AUTHENTICATION_FAILED, does not reach Dart. Apps can no longer tell a network problem apart from other registration failures.
We see this on many Android devices and versions in production and can't tell the failures apart.
Reproducing the issue
Setup
- Pixel 5, Android 14, Google Play services
- firebase_messaging 16.7.0, firebase_core 4.15.0 (Firebase Android BoM 34.19.0, firebase-messaging 25.1.3)
Steps
- With the device online, call
await FirebaseMessaging.instance.deleteToken(). This removes the cached token, so the nextgetToken()has to register again. - Block network access for Google Play services:
adb shell cmd connectivity set-chain3-enabled true adb shell cmd connectivity set-package-networking-enabled false com.google.android.gms - Call
await FirebaseMessaging.instance.getToken().
Result
After about 30 seconds, getToken() throws:
[firebase_messaging/unknown] java.io.IOException: FCM Registration failed!
The app's logcat has no FirebaseMessaging line about it.
Clean up
adb shell cmd connectivity set-package-networking-enabled true com.google.android.gms
adb shell cmd connectivity set-chain3-enabled false
Then call getToken() again to register a new token.
Firebase Core version
4.15.0
Flutter Version
3.44.9
Relevant Log Output
# getToken() after deleteToken(), Play services blocked
[firebase_messaging/unknown] java.io.IOException: FCM Registration failed!
# FCM's own token sync at app start, same failure
E/FirebaseMessaging: Topic sync or token retrieval failed on hard failure exceptions: FCM Registration failed!. Won't retry the operation.
[firebase_messaging/unknown] java.io.IOException: FCM Registration failed!
Flutter dependencies
Expand Flutter dependencies snippet
firebase_core 4.15.0
firebase_messaging 16.7.0
firebase_messaging_platform_interface 4.10.0
Additional context and comments
No response
- Dominant language
- Dart
- Stars
- 9.3k
- Forks
- 4.1k
- Avg merge
- 4d 17h
- Merged PRs (30d)
- 49
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from firebase/flutterfire
-
[cloud_functions]: Apple platforms ignore custom domains passed as regionPossibly taken @ragavendranbala-TSL claimed this today. OpenNeeds Attention platform: ios platform: macos plugin: functions type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
firebase/flutterfire#19015 · 2 comments ·
Maintainers usually reply within 4 days
-
Needs Attention platform: android plugin: messaging type: bug
Difficulty 4/5 3-5 days Newbie friendliness 45/100
firebase/flutterfire#19017 ·
Maintainers usually reply within 4 days
-
Needs Attention platform: web plugin: crashlytics type: enhancement
Difficulty 5/5 Over a week Newbie friendliness 34/100
firebase/flutterfire#19014 · 1 comment ·
Maintainers usually reply within 4 days
-
[firebase_storage]: Windows: getData() crashes with access violation (use-after-free of StorageReference in ReferenceGetData)Possibly taken @SelaseKay claimed this 3 days ago. Openblocked: customer-response platform: windows plugin: storage type: bug type: crash
Difficulty 4/5 3-5 days Newbie friendliness 35/100
firebase/flutterfire#18994 · 2 comments ·
Maintainers usually reply within 4 days
-
[firebase_auth_web]: Make the Auth emulator persistence from #18926 configurable instead of hard-gated on kDebugModePossibly taken @SelaseKay claimed this 1 day ago. OpenNeeds Attention platform: web plugin: auth type: enhancement
Difficulty 3/5 1-2 days Newbie friendliness 62/100
firebase/flutterfire#18992 · 1 comment ·
Maintainers usually reply within 4 days
All issues in firebase/flutterfire
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hajisensai/Fushi#4543 · 3 comments ·
Maintainers usually reply within 1 day
-
[video_player] _updatePosition sets isCompleted=true after 500ms when duration is Duration.zeroOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
chriskelly/wish-together#212 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
spotiflacapp/SpotiFLAC-Mobile#984 ·