[firebase_messaging]: Android getToken() errors lose their cause since firebase-messaging 25.1.0 ("FCM Registration failed!")

未关闭
#18,997 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

@SelaseKay 已经在做这个了。

开始于 2026年11月24日。

  • #18999 来自 @SelaseKay —— 未关闭

评估

难度
4/5
预计耗时
3-5 天
新手友好度
22/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
android, dart, java
领域
mobile

调研方向

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 内容生成。

描述

Needs Attention platform: android plugin: messaging reproduced type: bug
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

  1. With the device online, call await FirebaseMessaging.instance.deleteToken(). This removes the cached token, so the next getToken() has to register again.
  2. 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
    
  3. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

firebase/flutterfire 的其他 Issue

查看 firebase/flutterfire 的全部 Issue

相似的 Issue

更多 Dart Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。