Web push notifications require a secure context. In practice that means one of two things:
-
Production and staging: the site must be served over
https://with a certificate issued by a trusted Certificate Authority. Self-signed certificates are not trusted by browsers and will block service worker registration, and with it web push. -
Local development:
http://localhost,http://127.0.0.1and[::1]are treated as trustworthy origins by browsers, so service workers and web push work there over plain HTTP. You do not need a certificate to test on localhost.
Setting up a test environment
- Serve your test page from
http://localhost:<port>. Afile://path or a LAN address such ashttp://192.168.1.10is not a secure context and will not work. - Place the Pushwoosh service worker file at the root of that origin so its scope covers the page, and initialise the Web SDK with your Application Code and Device API token.
- If you must test on a hostname other than localhost, use a real HTTPS certificate (for example through a tunnelling service that terminates TLS for you) rather than a self-signed one.
- Browsers remember the notification permission per origin. Reset it in the browser's site settings between test runs, otherwise a previously denied prompt will not reappear.
- Safari on macOS and iOS requires the site to be added to the Home Screen / Dock for web push, which is worth reproducing in your test plan.
If you have any additional questions or concerns, please contact the Support team.
Comments
0 comments
Article is closed for comments.