21

I know you can send push notifications to a user who has installed the pwa. However, this always requires a server which sends that notification and also the end user device to be online to recieve and show it.

I was wondering if there is a way to "schedule" a push notification to be shown later, like it is possible on Android to be able to realize something like reminders for events, without the need to have an internet connections.

EDIT: Since Chrome 80, notification triggers are available as an origin trial.

kolaente
  • 1,252
  • 9
  • 22
  • 3
    How are you planning to get the data to be scheduled in first place? – karthick Jun 03 '19 at 18:32
  • 2
    Something like this: I build a website which shows events (for a conference for ex) as a pwa, so when the user visits the site, it downloads all events. These are stored offline. After this point, an internet connection should not be needed anymore. The user can then select events to get notfications for, put them in a list with favourites, whatever. When he chooses to get notified for a particular event, the notification to something like 5min before the event is scheduled and then shown when it was scheduled. – kolaente Jun 03 '19 at 18:56
  • My idea about this is background sync API... wondering if anybody managed to implement this with it. But I think it's possible! – mr.alex Jun 03 '19 at 20:42
  • I think it may be too unpredictable if running in the background. One option is to build something that allows the users to push reminders to THEIR calendar for the events that matter to them. Use the wheel that has already been built on every device. IMHO – Mathias Jun 03 '19 at 21:47

1 Answers1

31

There are at least 3 web APIs/specs in the development related to some form of the scheduled tasks. None of them are in production though.

Periodic Background Sync API

Main feature: it enables a web app to run tasks periodically while the device has network connectivity


Notification Triggers (a.k.a. Scheduled Notification API / Event Alarms)

Main feature: this allows to show a notification (nothing else) reliably at a specific time in the future, even if the device is offline


Scheduled Task API (Generic Alarms)

Main feature: schedule code to run at a specified time in the future - cron for the Web


So answering the original question: your choice is Notification Triggers API. Hopefully this will land in the browsers soon.

Maxim Salnikov
  • 704
  • 1
  • 9
  • 13
  • 7
    Notification triggers are [now available in Chrome (behind a flag)](https://developers.google.com/web/updates/2020/02/nic80#notification_triggers). I've started using them and it is working pretty good so far. – kolaente Feb 24 '20 at 19:01
  • 1
    Notification Triggers is the API you want to have an eye on. It's currently available behind a flag, but will enter a new origin trial soon. For more details, see the [article](https://web.dev/notification-triggers/). – DenverCoder9 Dec 16 '20 at 16:22
  • 1
    As of Dec 2021 Google are "currently not pursuing shipping this API", real shame. – wjdp May 22 '22 at 22:13