简体   繁体   中英

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.

I added the SHA1 for each app in firebase, each app has 2 SHA1

1- App signing key certificate

2- local SHA1

also the "Android key (auto created by Firebase)" is restricted with the SHA1 keys for the apps

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

What I'm missing here? Thanks

Found the answer in this flutterfire issue .

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM