Skip to content

Installing the SDK

Hosting the service worker (sw.js, swPath, swScope), apiBase, and the iPhone/iPad Home Screen rule.

The SDK needs a service worker on your own domain. The default swPath is /sw.js — host our sw.js there, or put it somewhere else on the same domain and pass that path as swPath (for example "/folder/sw.js"). The WordPress plugin serves its own service worker, so there's no file to upload. Shopify doesn't let you upload this file — see Shopify.

Already have a service worker at /sw.js (a PWA, for example)? Keep it, and host relaybell's sw.js in its own folder with swPath and swScope (for example "/relaybell/sw.js" and "/relaybell/"). A worker with a narrower scope still receives push, so the two don't clash.

apiBase is the relaybell address the SDK talks to. If you leave it out, the SDK uses the address it was loaded from — https://relaybell.com for the snippet above — so the snippet works either way.

Note

On iOS/iPadOS, web push only works once a visitor adds your site to their Home Screen (Apple's rule). The SDK detects iOS and shows an "Add to Home Screen" hint automatically.