Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rakeshsalian039 opened this issue Feb 9, 2022 · 7 comments

Comments

@rakeshsalian039
Copy link

❗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
Copy link
Collaborator

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
Copy link
Author

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

@rlepinski
Copy link
Collaborator

@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
Copy link
Collaborator

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
Copy link
Author

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

@rlepinski
Copy link
Collaborator

@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
Copy link
Collaborator

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());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants