[firebase_messaging]: Android getToken() errors lose their cause since firebase-messaging 25.1.0 ("FCM Registration failed!")
维护者通常 4 天内回复
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- Dart
- 星标
- 9.3k
- 派生
- 4.1k
- 平均合并
- 4 天 17 小时
- 30 天内合并 PR
- 49
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/flutterfire 的其他 Issue
-
[cloud_functions]: Apple platforms ignore custom domains passed as region可能已有人在做 @ragavendranbala-TSL 今天认领。 未关闭Needs Attention platform: ios platform: macos plugin: functions type: bug
难度 2/5 1-3 小时 新手友好度 78/100
firebase/flutterfire#19015 · 2 条评论 ·
维护者通常 4 天内回复
-
Needs Attention platform: android plugin: messaging type: bug
难度 4/5 3-5 天 新手友好度 45/100
firebase/flutterfire#19017 ·
维护者通常 4 天内回复
-
Needs Attention platform: web plugin: crashlytics type: enhancement
难度 5/5 一周以上 新手友好度 34/100
firebase/flutterfire#19014 · 1 条评论 ·
维护者通常 4 天内回复
-
[firebase_storage]: Windows: getData() crashes with access violation (use-after-free of StorageReference in ReferenceGetData)可能已有人在做 @SelaseKay 于 4 天前认领。 未关闭blocked: customer-response platform: windows plugin: storage type: bug type: crash
难度 4/5 3-5 天 新手友好度 35/100
firebase/flutterfire#18994 · 2 条评论 ·
维护者通常 4 天内回复
-
[firebase_auth_web]: Make the Auth emulator persistence from #18926 configurable instead of hard-gated on kDebugMode可能已有人在做 @SelaseKay 于 2 天前认领。 未关闭Needs Attention platform: web plugin: auth type: enhancement
难度 3/5 1-2 天 新手友好度 62/100
firebase/flutterfire#18992 · 1 条评论 ·
维护者通常 4 天内回复
查看 firebase/flutterfire 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
hajisensai/Fushi#4543 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
dart-lang/dart_style#1928 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
chriskelly/wish-together#212 ·
维护者通常 1 天内回复