-
Notifications
You must be signed in to change notification settings - Fork 6
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
Replacing/cancelling a notification after a duration #6
Comments
You can cancel previously scheduled notifications: https://web.dev/notification-triggers/#canceling-a-scheduled-notification. Does this work for you? |
This cancels the notification right now, which doesn't help the use cases I described above. The goal is really to schedule one or more updates to a notification, at a later point in time. Ideally by scheduling more notifications with the same tag, which would have the effect of replacing a displayed notification with the same tag. Currently, there can seemingly only be a single notification with a given tag, immediate or scheduled, which means that scheduling one immediately cancels and hides any currently shown one. Scheduling a cancellation was only suggested above as a means to use separate tags but ensure that notifications aren't concurrently shown. Can you see any alternative way of implementing either of the use cases I described above? Should this be possible? |
I find this an interesting question. Most of us regard notifications as an "act upon it or throw it away" item. However, what this use case shows, is that some users seem to "temporarily keep" notifications as a kind of short term reminder or post-it note. The notifications pane than becomes a kind of secondary screen, which in a sense it is. As a late answer to @theefer, you probably would want to keep the type A ETA timer inside the core app and use a service worker notification only for the type B vibration alarm. |
As far as I was able to tell, there is no way to replace or cancel a notification (scheduled or immediate) at a given later point in time?
I am working on an application that involves baking timers and I would like to show an initial notification (A) with the ETA, and replace it with a different, buzzing notification (B) when the timer elapses. So far my attempts seem to reveal that if I use the same notification tag, there can only ever be one notification with it, so showing an immediate notification A and then scheduling a notification B for later with the same tag results in A being cancelled and only B appearing when its time arrives. I can use different tags so both would show, but then A would remain visible once B appears.
A more intensive use case would be to periodically update a notification on a schedule. Think of how the native Android timer displays the time remaining, updated every second. Even if once a second might be too greedy, it would be great to be able to refresh the ETA displayed in the notification every minute, or even every 5-10 minutes. I was hoping to achieve this by scheduling "notification updates", but as per the scenario above, it doesn't seem possible to schedule updates to a notification?
Am I missing anything, or is there any way to support these use cases?
The text was updated successfully, but these errors were encountered: