Reputation: 1302
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.
Upvotes: 23
Views: 9072
Reputation: 2261
At the time of writing (November 2024), periodic-sync is supported by Chrome (both on desktop and on Android) and Edge, as well as a few other platforms. Unfortunately no support for Safari or Firefox. (I don't think iOS will ever want to support something like periodic-sync, because it's my understanding that they want people to publish native apps in their app store)
I've tested periodic-sync myself on Chrome for Android and Chrome for Desktop, and it works. Unfortunately I haven't found a real alternative for the other platforms (maybe using setTimeout could work in some cases but it requires the app to be open)
Upvotes: 1
Reputation: 724
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.
Upvotes: 31