简体   繁体   English

Flutter Android firebase 通知在发布模式下不起作用

[英]Flutter Android firebase notification doesn't work in release mode

We have two apps the first app sends a request to Backend(Laravel) then the backend sends the notification to firebase(we receive the correct response from firebase) and the second app should receive a notification, everything works fine in the debug mode(when my phone is connected to Android Studio) once I release it on Google play it doesn't work, the second app doesn't receive any Notification.我们有两个应用程序,第一个应用程序向后端(Laravel)发送请求,然后后端向 firebase 发送通知(我们从 firebase 收到正确的响应),第二个应用程序应该收到通知,在调试模式下一切正常(当我的手机连接到 Android Studio)一旦我在 Google Play 上发布它就无法运行,第二个应用程序没有收到任何通知。

I added the SHA1 for each app in firebase, each app has 2 SHA1我在 firebase 中为每个应用程序添加了 SHA1,每个应用程序有 2 个 SHA1

1- App signing key certificate 1- 应用签名密钥证书

2- local SHA1 2- 本地 SHA1

also the "Android key (auto created by Firebase)" is restricted with the SHA1 keys for the apps应用程序的 SHA1 密钥也限制了“Android 密钥(由 Firebase 自动创建)”

The issue only happens in release mode该问题仅发生在发布模式

I did download a new version of google-services.json after adding the keys and uploaded the bundle to play console添加密钥后,我确实下载了新版本的 google-services.json 并将包上传到控制台

What I'm missing here?我在这里缺少什么? Thanks谢谢

Found the answer in this flutterfire issue .这个 flutterfire 问题中找到了答案。

You have to prepend the following line to your background message handler:您必须将以下行添加到后台消息处理程序中:

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

It will prevent the handler from being removed during tree shaking when building for release mode.它将防止处理程序在构建释放模式时在 tree shaking 期间被删除。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 flutter:fcm android 推送通知在发布模式下不起作用,在调试模式下起作用 - flutter: fcm android push notifications doesn't work in release mode and work in debug mode 背景上的 Firebase 通知不适用于 Android - Firebase Notification onBackground don't work for Android Flutter web:Firestore 在运行调试模式下工作,在 bilud 发布模式下不工作 - Flutter web: Firestore work in run debug mode and don't work in bilud release mode Firebase 在 Android Studio 模拟器上不起作用 - Firebase doesn't work on Android Studio Emulator Firebase 登录错误仅在 android 发布模式下 - Firebase SignIn error only in android release mode 我正在尝试使用 Firebase 在 Flutter 中使用 Google 注销,但它不起作用 - I'm trying to signOut with google in Flutter with Firebase and it doesn't work Flutter Web Firebase Auth 的持久性在 PWA 上不起作用 - Flutter Web Firebase Auth's persistence doesn't work on PWA 当 flutter 应用程序处于后台时,通知不会进入发布模式 - Notification is not coming in release mode when flutter app is in background Flutter - firebase_app_check 在发布模式下不工作,如何解决? - Flutter - firebase_app_check not working in release mode, how fix it? 应用程序不在发布模式下构建 - Application doesn't build in release mode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM