-
Notifications
You must be signed in to change notification settings - Fork 83
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
Notification doesn't receive click event when the activity is closed #123
Comments
A workaround to this can be that when you create the notification you set a flag. If the user taps directly on the notification when the app is still open you do your action and you unset the flag. If the app goes background without the notification tapped than when the app returns you check the flag and if its set then you know that there was a notification so you need to do the action.. |
That doesn't sound right. What happens if:
I solved my problem just creating native Android notifications, but it would be great if this was possible using this plugin as well. |
You are right, I missed this case. |
Facing the same problem here. I tried to implement native Android notifications too but couldn't get it to work... |
I needed local notifications so what I did is to create a dependency service where I call the following code when the app is running in the foreground:
This code will display a local notification that will stay in the notifications drawer as long as the app is running (even in the background). When we click on the notification then in MainActivity I do the following check in OnResume |
You can now click notifications from the NotificationCenter and have it continue the code in your app, if you use the Notify method with the Callback. (Starting with 3.3.0-pre1) Marking this as closed. Please comment again if the issue is still there, or create a new issue if it works but has a bug. |
I'm using this plugin to show notifications in many scenarios. One of them is push notifications. When I receive a push notification I show a toast using the service
DependencyService.Get<IToastNotificator>();
and specifyingIsClickable = true
.If the activity is open when the notification is clicked, I get the callback as expected, but I close the activity in the task manager and then click the notification, nothing happens.
More specifically, if I run the debugger, I get that
result.Action
is Timeout, no matter if I click or dismiss the notification.I believe this has something to do with the fact that
NotificationBuilder
registers receivers against the activity, but if the activity is closed, then there's nothing that can receive the events.The text was updated successfully, but these errors were encountered: