当应用程序在后台运行时,Android 12 firebase 推送通知不起作用

And*_*rew 7 push-notification firebase firebase-cloud-messaging android-12

我正在从firebase>compose notification page发送测试推送通知。我在 Android 8、9、10、11 上收到推送通知,但在 12 上则没有。

我有两台运行 Android 12 的设备:实体手机 Samsung S22 和 Pixel 模拟器。在这两种情况下,推送通知都不会出现在通知托盘中。

笔记:

  • 我说的是当应用程序在后台运行时系统在通知托盘中显示的通知。当应用程序位于前台时,onMessageReceived 在 Android 12 上按预期工作。
  • 令牌是正确的
  • 在所有情况下,我都会关闭应用程序以便在通知托盘中推送
  • 如果我使用android:exported="false"- 仍然不起作用

我在 android 清单中的服务:

        <service
            android:name=".old.push.FCMHandlerService"
            android:enabled="true"
            android:exported="true">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
Run Code Online (Sandbox Code Playgroud)

ale*_*aru 4

就我而言,我使用的是旧版本的 React Native Firebase,并且我对待处理的 Intent 进行了更改。然而,错误是通过在应用程序文件夹内的 build.gradle 中使用旧依赖项而出现的,该依赖项尚未解决挂起的意图更改。我刚刚升级了以下版本的“com.google.firebase:firebase-messaging:xxx”

implementation "com.google.firebase:firebase-iid:21.1.0"
implementation "com.google.firebase:firebase-messaging:22.0.0"
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请检查此问题: https://github.com/EddyVerbruggen/nativescript-plugin-firebase/issues/1876