A simple browser demo for sending and receiving push notifications via Ably. This page wont store your API key, but it is recommended to create a new API KEY for testing.
- An Ably account and API key
- The API key must have the following capabilities on the
push:*namespace (or all channels):subscribepublishpush-subscribe
- Python 3 (or any static file server — service workers require HTTP, not
file://)
cd path/to/push-notifications
python3 -m http.server 8080Then open http://localhost:8080 in your browser.
- Enter your API key in the Connection card and click Connect
- Click Subscribe — this registers the service worker and requests notification permission
- Publish a text message — triggers a browser notification
- Publish a data message — delivered silently; logged to the page and browser console only
You can pre-fill the API key and channel via query params (useful during development):
http://localhost:8080?key=YOUR_API_KEY&channel=push:demo
| File | Purpose |
|---|---|
index.html |
UI and styles |
app.js |
Ably SDK initialisation, channel subscribe, publish logic |
service-worker.js |
Handles background push events and notification clicks |