【问题标题】:Flutter Android firebase notification doesn't work in release modeFlutter Android firebase 通知在发布模式下不起作用
【发布时间】:2022-11-22 15:23:38
【问题描述】:

我们有两个应用程序,第一个应用程序向后端(Laravel)发送请求,然后后端向 firebase 发送通知(我们从 firebase 收到正确的响应),第二个应用程序应该收到通知,在调试模式下一切正常(当我的手机已连接到 Android Studio)一旦我在 Google Play 上发布它就无法运行,第二个应用程序不会收到任何通知。

我在 firebase 中为每个应用程序添加了 SHA1,每个应用程序都有 2 个 SHA1

1- 应用签名密钥证书

2- 本地 SHA1

应用程序的 SHA1 密钥也限制了“Android 密钥(由 Firebase 自动创建)”

该问题仅发生在发布模式

添加密钥后我确实下载了新版本的 google-services.json 并将包上传到控制台

我在这里缺少什么? 谢谢

【问题讨论】:

    标签: android flutter firebase google-cloud-platform


    【解决方案1】:

    this flutterfire issue 找到了答案。

    您必须将以下行添加到后台消息处理程序中:

    @pragma('vm:entry-point')
    Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
        // handle message
    }
    

    它将防止处理程序在构建释放模式时在 tree shaking 期间被删除。

    【讨论】:

      猜你喜欢
      • 2021-09-30
      • 2022-11-17
      • 2022-08-08
      • 2021-04-28
      • 1970-01-01
      • 2021-04-08
      • 2022-07-27
      • 2020-12-26
      • 2021-05-02
      相关资源
      最近更新 更多