-
-
Notifications
You must be signed in to change notification settings - Fork 115
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
bug(messaging): notificationReceived
fires only for the last message received while the app is killed
#210
Comments
Thank you for your request. I will have a look. Should be a bug. |
I looked at it and was able to reproduce the problem. The problem also exists on iOS. However, I cannot currently fix the bug on iOS because Capacitor does not allow it. I have created a feature request. (see ionic-team/capacitor#5967) |
From the issue you opened, I read that immediate handling of data-only notifications (eg displaying a local notification in response) isn't even the intended behavior? So the fact that (although just one) notifications are handled only when the app launches the next time is intended? |
Immediate handling of data-only notifications is the intended behavior, but only if the application is running in the background (so only if the application was not force closed). |
Is there any way of achieving exactly that? Handling notifications while the app has been killed? |
Yes, with native code (e.g. Capacitor Plugin). |
Chat feature in the app should display notifications as soon as they come (minus delay and restrictions, but before the user manually opens the app). As user could still just dismiss the notification, I need to perform operations on it before the user can dismiss it - so normal message notifications are unfeasible and data notifications don't work from within JS. So guess that means I have to learn Java after all. |
You could send two notifications (one Notification message and one Data message) at the same time. This is how a client of mine does it with a similar problem. |
That is a nice idea. However, it would mean double the calls to firebase cloud functions (if I had a server that could handle a call on every message, I'd just save them to the DB and fetch them on login)... So yes, I think I will have to investigate the Java side of things in the coming days. |
Just for the sake of being thorough: I just tested the behavior in a production (non-debug) app via internal testing track on google play.
I did this test because I learned that push notifications allegedly have different behavior in debug vs production and also Android is said to kill services associated with an app on close if the app is debug. |
This might be a bit off-topic, but for anyone passing here on the hunt for a solution to my problem, adding your own FirebaseMessagingService extender doesn't play well with capacitor either. I've written about that here: ionic-team/capacitor-plugins#1211 (comment) |
notificationReceived
-listener doesn't fire if app is killednotificationReceived
fires only for the last message received while the app is killed
notificationReceived
fires only for the last message received while the app is killednotificationReceived
fires only for the last message received while the app is killed
This should be fixed in Capacitor 5 (see ionic-team/capacitor#5967 and #355). |
Plugin(s):
"@capacitor-firebase/messaging": "^1.1.0"
Platform(s):
Android
Current behavior:
If a data-only notification is received while the app is killed or the device is in doze, the
notficationRecieved
listener event does not fire. When the app is opened the next time, the listener fires only for the last message recieved while the app was killed. Every other message is dropped.Expected behavior:
Code given to the listener should be executed regardless of doze or killed app. Documentation states If the app is in the background, then this listener is only called on data push notifications., but does not make any statement about the app being killed.
Steps to reproduce:
Add listener and send data-only notification to device while app is killed:
message:
Capacitor doctor:
The text was updated successfully, but these errors were encountered: