What are web push notifications, and when to use them
Web push lets a site or PWA send a message even when the user hasn't opened it. Used badly it is annoying, and in some conditions it isn't dependable. Here are the facts.
Web push is the notification that appears on a phone or desktop screen from a website or PWA, even when the page is closed. For a product where response time matters it is a useful tool, provided you know its limits.
How it works
- The site asks the user for permission to notify.
- The browser creates a subscription tied to the browser's push service.
- The subscription is sent to your server and stored.
- When an event happens, the server sends the message through that service.
- The service worker receives the message in the background and shows the notification.
The server proves its identity with the Web Push standard and VAPID keys. The user can withdraw permission at any time.
Where it works
| Platform | Status |
|---|---|
| Android (Chrome and similar browsers) | Works |
| Desktop (Windows, Mac, Linux) | Works |
| iOS (iPhone) | Only when the site has been added to the home screen |
For installing as an app, see what a PWA is.
An important fact: dependence on a push service
Web push passes through the browser's or operating system's own services, such as Google's, Apple's or Mozilla's. The practical consequences:
- If access to those services is restricted or slow, a notification may arrive late or not at all.
- In Iran, without a change of IP, this dependence may not be reliable.
In the products I build, web push is one of several routes, with messengers and email alongside it as the more dependable path.
Best practice
- When you ask for permission. Don't ask the moment someone arrives. Ask when the value is clear to the user.
- Useful content. Only messages the user is waiting for, not adverts.
- User control. A simple way to turn it off and to set categories.
- Low volume. Every extra notification raises the chance it gets switched off.
- Clear text. A title and one short sentence that makes sense without opening.
- Privacy. Don't put sensitive information in the text; the lock screen may be seen.
When it is appropriate
| Use | Suitable |
|---|---|
| A new message for the panel admin | Yes |
| Order status | Yes |
| A reminder the user asked for | Yes |
| Mass promotion | Usually not |
| A critical message with no second route | No |
Implementation at a glance
- A service worker file to receive and display
- Storing subscriptions in a database and removing expired ones
- VAPID keys kept secret
- Sending from the server on defined events
- Error handling: an invalid subscription gets deleted
For an admin panel the feature pairs well with good panel design: a new message arrives, the admin is told, and replies quickly.
The takeaway
Web push is a valuable tool for shortening response time, but it is neither the only route nor always dependable. Use it with informed permission, useful content and a fallback route.
If you'd like your product or panel to have notifications and an app-like experience, talk to me.