Service Worker and Push Delivery in a PWA

The service worker is what makes push delivery possible in a PWA — it keeps running in the background even after the app tab is closed. Without a registered service worker, there is no subscription and no notification on screen at all. Here is how push delivery actually works under the hood, and what APEX already handles for you.

What a service worker is and why a PWA needs it

A service worker is a JS script the browser runs on its own thread, with no access to the page DOM and no dependency on an open tab. It installs, activates, and then lives in the background, handling offline caching, background sync, and — most relevant for arbitrage — push notifications. A registered service worker is what separates a real PWA from a plain landing page: without it, building a push subscriber base isn't possible at all.

How push delivery actually works

The user grants notification permission, and the browser's PushManager creates a subscription — a unique endpoint on the browser's push service. Your server sends the payload to that endpoint, the push service delivers it to the device, and it wakes the service worker with a push event. Inside that event the SW calls showNotification — only then does the user actually see anything on screen.

What has to be in place before push works at all

The PWA must be served over HTTPS — without a valid certificate the browser won't register a service worker. The worker's scope has to cover the pages where you collect subscriptions, and it needs to finish registering before you request a subscription. Permission always comes from the user through the native browser prompt — you can't skip that step, only lead into it well with a pre-lander.

What APEX already handles for you

APEX deploys and maintains the service worker and the whole subscription pipeline itself, so you don't need to write JS or deal with PushManager directly. From there the push engine takes over: subscriber base collection, geo and behavior segmentation, triggered flows, and scheduled campaigns — everything that happens after a successful subscription is ready out of the box. Custom domains with automatic HTTPS and one-click rotation also remove the certificate headache when you switch domains.

Common delivery problems and where to look

If push stops arriving, check first whether the user is stuck on an older service worker — the browser can keep running the previous version until every tab with the site is closed. Another common case: the user declined the notification prompt once, and the browser won't show it again automatically. On iOS, web push only works from iOS 16.4 onward, and only for a PWA added to the Home Screen — a regular Safari tab never gets push. For debugging, the Application → Service Workers tab in devtools shows registration status and errors directly.

FAQ

Will push notifications still arrive if the user closed the PWA tab?
Yes — that's the whole point of a service worker: it runs in the background independently of any open tab, as long as the browser process is alive and OS-level notifications are enabled.
Why do some subscribers miss a push after I update the campaign logic?
They're probably still running an older service worker version — browsers only switch to the new one after every tab with the site closes, or after an explicit skipWaiting.
Does web push work on iPhone?
Yes, but only from iOS 16.4 onward, and only if the PWA was installed via Add to Home Screen — a regular Safari tab has no access to the Push API.
Do I need to write my own service worker code when using APEX?
No — APEX registers and maintains the service worker automatically. You just configure segments and campaign flows in the push engine.
Build your PWA in APEX in minutes

Cloaking, anti-bot, push, split tests and your own domains — in one service.

Get started free

Read also