Push notifications
Opt-in web push with VAPID, the MotiSig service worker, and subscribePush().
Web push is opt-in. The SDK does not register a service worker or prompt for permission unless you enable push (data-push="true"). After the visitor grants permission, the subscription is registered with enabled: true on the MotiSig backend.
Prerequisites
- Configure Web (VAPID) under Settings → Providers → Push → Web in the MotiSig app.
- Add your site's origin under Settings → API Keys → SDK → Allowed web domains — Client API calls from the page and service worker (open/click tracking) require it. See Allowed web domains.
- Host the service worker at your site root: create
public/motisig-sw.jswithimportScripts("https://motisig.ai/cdn/web/v1/motisig-sw.js");(see Service worker below). - Serve your site over HTTPS.
Script tag
<script
src="https://motisig.ai/cdn/web/v1/motisig.js"
data-sdk-key="YOUR_SDK_KEY"
data-project-id="YOUR_PROJECT_ID"
data-push="true"
async
></script>Optional: data-push-auto-subscribe="true", data-service-worker-path="/motisig-sw.js".
Global API
window.motisig.subscribePush();
window.motisig.unsubscribePush();
window.motisig.setPushEnabled(true);
window.motisig.getPushPermission();Service worker
Create public/motisig-sw.js (or equivalent) at your site root with this one-line stub:
importScripts("https://motisig.ai/cdn/web/v1/motisig-sw.js");The stub must be served from your origin at /motisig-sw.js — browsers require same-origin registration. importScripts() loads the real worker from the MotiSig CDN and auto-updates when we ship fixes.
iOS Safari
Web push on iOS requires the site to be added to the Home Screen (PWA). subscribePush() returns { ok: false, reason: 'unsupported' } when push is unavailable.
User identity
subscribePush() registers the subscription for the identified user or anonymous visitor id. If anonymous tracking is disabled and no user is identified, it returns { ok: false, reason: 'no_user' }.