javascriptprogressive-web-apps

Is there a way to schedule offline notifications in a pwa?


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.


Solution

  • 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.