[英]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.