Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 349
kolaente Avatar asked Jun 03 '19 18:06

kolaente


People also ask

Can a PWA send notifications?

all support native push notifications. Beyond the browser Windows and Android both support push. And if you are wondering if Edge, FireFox or Chrome on iOS support push, they don't.

Does push notification work offline?

There is Notifications which works offline, but you cannot call it from "background" (e.g. when your web page is closed).


1 Answers

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

  • Explainer: https://github.com/beverloo/periodic-background-sync
  • Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=925297
  • Status: https://www.chromestatus.com/feature/5689383275462656 (in dev)

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)

  • Explainer: https://github.com/beverloo/notification-triggers
  • Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=891339
  • Status: https://www.chromestatus.com/feature/5133150283890688 (proposed, part of Project Fugu)

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)

  • Explainer: internal design docs only
  • Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=889077
  • Status: TBD, part of Project Fugu

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.

like image 186
Maxim Salnikov Avatar answered Oct 16 '22 21:10

Maxim Salnikov