EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 441 forks source link

Handling notification - Best practices #625

Open bzaruk opened 6 years ago

bzaruk commented 6 years ago

I am writing about this after a long searching about this issue and without any success.

I'm trying to implement a navigation after notification tray tap functionality. In the current situation I encounter 2 major issues that i'm still not able to properly figure out:

issues tl;dr:

  1. When app is in background, the onMessageReceived is not called
  2. When app is accessed not via notification tray click - notification icon doesn't disappear

I'm using android:launchMode="singleTask" on my AndroidManifest.xml to prevent restarting the app on each notification tray click.

For simplicity, lets say that i'm handling chat messages arrival using firebase.

Application state:

I am only talking only about Android platform (didn't test it on IOS yet).

I would be happy about any kind of help? even a demo would be awesome!

Thank you a lot!

manijak commented 6 years ago

I've just found out that using android:launchMode="singleTask" is the cause of onMessageReceived not being called when the app is in the background. It will open the app, but nothing more.

Remove android:launchMode="singleTask", and the callback will work. But it will cause android to create new instances of your app when using, for example, DynamicLinks.

bzaruk commented 6 years ago

Hey your proposed solution is not quite a solution; the app is recreated and a lot of time is spent to view it. I prefer a allropriate solution as recreating the app will also lose user context

manijak commented 6 years ago

I understand, have the same issue as you. Never said that it was a solution, just explaining why onMessageReceived in your case is not being hit.

bzaruk commented 6 years ago

@EddyVerbruggen - maybe you have any wisdom saying about the issue?