-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Help for PR research: ways to cancel specific notifications when removing an app from Android's task list #2457
Comments
From the comment you linked:
There is now such a method available |
Thanks for the pointer. : ) I think that in this case, Flutter Local Notifications is probably not passing all metadata it has to the Java compat library, so while it's possible to fetch all notifications that way, the compat library probably doesn't provide the info needed to know which to close. I could be wrong, since there's a lot of code, and I haven't found everything I might need yet. |
Wouldn't the ID be enough? |
I think what's needed is some kind of mapping between notification IDs and whether they were created with a parameter that marked them as needing cleanup on app termination. That's because any specific notifications may or may not have this setting. If we remove all of the notifications, that doesn't fit the original suggestion. I like the idea in the comment we linked to, which is to set an attribute on notifications that need this behavior. And I suspect that info is not passed to the compatibility library, so the map has to come from somewhere, perhaps over a Method Channel from Dart to Java, or it gets stored by the Java part of Flutter Local Notifications while alerts are created and removed. I'm not super clear on the code yet, but this is my sense of how it works and could work. |
Okay, got it, I was thinking that all notifications will be dismissed when the app closes. You're suggesting doing it on a per-notification basis, so yeah I'm not sure if getting all the IDs is actually useful. Since these notifications are only alive so long as the app is, we can use ephemeral memory instead of persistent storage, right? Shared preferences would imply we want these values to survive after app termination, but we don't. Does the Java/kotlin side have an object that is alive the whole time? If so, can we just store the notification IDs in a list there? |
I'm creating an issue to continue the discussion linked here, because I'm interested in making a PR to implement this behavior: #207 (comment)
The guidance there is helpful, but I see that Shared Preferences aren't used on the Dart side any more. Do you suggest querying all of the active alert data in Java via a method channel, when
onTaskRemoved()
is called, or would it make more sense to store the data in shared preferences on the Java side, as alerts are created one-by-one?With the latter approach, Shared Preferences may need to be updated when old notifications are closed and replaced by new ones, sometimes with the same ID number.
If you have any pointers or opinions, I'd love to hear them. Thanks : )
The text was updated successfully, but these errors were encountered: