Flutterfire: [firebase_messaging] What I can do with myBackgroundMessageHandler static function/top level function ?

Created on 15 Nov 2019  路  5Comments  路  Source: FirebaseExtended/flutterfire

I can't show dialog :/
show me some examples of case use this function when using fcm background handle pls !
I also print value in this function but nothing to see
```
static Future myBackgroundMessageHandler(
Map message) {
if (message.containsKey('data')) {
// Handle data message
final dynamic data = message['data'];
print(data);
}

if (message.containsKey('notification')) {
  // Handle notification message
  final dynamic notification = message['notification'];
  print(notification);
}
return null;
// Or do other work.

}```

messaging documentation enhancement

Most helpful comment

Yeah same I have no idea how to access anything from the background. Everything is null.

All 5 comments

Yeah same I have no idea how to access anything from the background. Everything is null.

I was facing the same issue, and came up with a solution using Dart's ReceiverPort and SendPort. Since I'm new to Flutter and Dart, my knowledge is limited. Not sure how efficient my solution is. Here: https://github.com/FirebaseExtended/flutterfire/issues/1878#issuecomment-589257971

I was facing the same issue, and came up with a solution using Dart's ReceiverPort and SendPort. Since I'm new to Flutter and Dart, my knowledge is limited. Not sure how efficient my solution is. Here: #1878 (comment)

This case is app is running. But when app was killed everything is null.

I was facing the same issue, and came up with a solution using Dart's ReceiverPort and SendPort. Since I'm new to Flutter and Dart, my knowledge is limited. Not sure how efficient my solution is. Here: #1878 (comment)

This case is app is running. But when app was killed everything is null.

Yes. You're right. I can receive notification messages from FCM when the app is terminated, but I can't receive any data messages. In other words, onBackgroundMessage is never fired. As mentioned over here: https://pub.dev/packages/firebase_messaging#receiving-messages. Is there something similar to onAppTerminatedMessage? Is there any work around for this? Or I should probably just fetch the latest info through an API when the app comes to foreground.

Hey all 馃憢

As part of our roadmap (#2582) we've just shipped a complete rework of the firebase_messaging plugin that aims to solve this and many other issues.

If you can, please try out the dev release (see the migration guide for upgrading and for changes) and if you have any feedback then join in the discussion here.

Given the scope of the rework I'm going to go ahead and close this issue in favor of trying out the latest plugin.

Thanks everyone.

Was this page helpful?
0 / 5 - 0 ratings