Is it possible to trigger push notifications (on iOS and/or Android) from a web application while offline?
As I understand it, even with a Service Worker background process, push notifications are always triggered via a server - which seems to preclude reliable offline reminders or anything like that.
Progressive Web Applications (PWA) make native push notifications available to any website using a service worker on just about every platform and browser. The power of web app push notifications is being able to engage customers without a native app.
Our app is caching its resources on install and serving them with fetch from the cache, so it works even if the user is offline.
The Push API allows the app to display these notifications even when the app is offline. On mobile, Push notifications can even show up if the phone is locked. Background service workers make it possible to send messages when offline.
This means the browser can have no windows open, and you'll still receive the push message in your service worker, because the browser in running in the background. The only time a push won't be received is when the browser is completely closed, i.e. not running at all (no marking).
There is Notifications which works offline, but you cannot call it from "background" (e.g. when your web page is closed).
"Background task" (or similar feature) is not available yet on the web, and I'm not sure it's a good idea to bring that power to the web. The closest thing you can do that sounds like "background" is MediaSession that allows you to play music and handle media controls on your hardware devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With