Skip to content
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

Open
theefer opened this issue Jul 5, 2020 · 3 comments
Open

Replacing/cancelling a notification after a duration #6

theefer opened this issue Jul 5, 2020 · 3 comments

Comments

@theefer
Copy link

theefer commented Jul 5, 2020

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?

@tomayac
Copy link

tomayac commented Jul 20, 2020

You can cancel previously scheduled notifications: https://web.dev/notification-triggers/#canceling-a-scheduled-notification. Does this work for you?

@theefer
Copy link
Author

theefer commented Jul 26, 2020

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?

@stroobandt
Copy link

I find this an interesting question.
What @theefer really is asking for, is a way to periodically update the text in a notification; in this case, with an estimated time of arrival (ETA) or countdown time.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants