urbanairship / airship-flutter

Flutter integration
Other
17 stars 16 forks source link

Cannot handle notification like Firebase "myBackgroundMessageHandler" in Killed state. #116

Closed rakeshsalian039 closed 2 years ago

rakeshsalian039 commented 2 years ago

❗For how-to inquiries involving Airship functionality or use cases, please contact (support)[https://support.airship.com/].

Preliminary Info

What Airship dependencies are you using?

5.1.1 ### What are the versions of any relevant development tools you are using? Android studio # Report ### What unexpected behavior are you seeing?

We could handle almost every scenario using Airship.Except Handling notification in killed state. We had implemented firebase for Notification, it has a function i.e "myBackgroundMessageHandler" which can handle and update a notification even in the killed state. I couldn't find any function or handler in Airship which can handle during killed state. Right now when we receive a notification and we click on it and enter inside the app. "Airship.onPushReceived .listen((event)" is been getting after we enter inside the App.

What is the expected behavior?

During killed state we want to have our own custom notification(Like a call feature). We want "Airship.onPushReceived .listen((event)" to be called even in killed state. (Specifically for android)

Please help us with this issue or any help so that we can handle this behaviour.

What are the steps to reproduce the unexpected behavior?

By sending notification in android app during killed state. Check if there is any way to know we have receive a push during killed state.

Do you have logging for the issue?

rlepinski commented 2 years ago

Right now we don't support waking the app up in the background, but would like to. I believe this requires isolates but I will see what other options flutter supports.

rakeshsalian039 commented 2 years ago

Sure, Please let me know. If there is any way I can handle.

rlepinski commented 2 years ago

@rakeshsalian039 I dug into the firebase implementation and they are indeed using an isolate. We attempted this in the past but it was a bit messy - https://github.com/urbanairship/airship-flutter/pull/84/files

I will try again this week on isolate support, hopefully in a way that wont completely change the plugin usage.

rlepinski commented 2 years ago

Not in 5.3.0 but will target the next release. Most likely will require breaking APIs so probably a 6.0.0 release.

rakeshsalian039 commented 2 years ago

So what is the timeline for 6.0.0 release? This is critical for one of the feature we have implemented.

rlepinski commented 2 years ago

@rakeshsalian039 We are working on it now. Give us a few more days to get a better idea when the work will be done.

As a workaround, you could use both Airship and the firebase plugin. With firebase you can use the myBackgroundMessageHandler even for Airship pushes. The only thing you would have to do is extend the firebase messaging service from the firebase plugin, call through to airship, and register the new service at a higher priority.

rlepinski commented 2 years ago

Released in 5.4.0:

Future<void> backgroundMessageHandler(
    Map<String, dynamic> payload,
    Notification? notification) async { 
  // Handle the message
  print("Received background message: $payload, $notification");
}

void main() {
  Airship.setBackgroundMessageHandler(backgroundMessageHandler);
  runApp(MyApp());
}