Articles › Technical Insights, Web Push Notifications

Silent push: sending web push messages without displaying notifications

  • # permission
  • # push-api
  • # web-notifications

When you hear "web push" you probably think about notifications... but that is not necessary true. In theory, the web push technology could be used for delivering messages or updates to the web app, without displaying a notification to a user.

For example, you may want to send a notification to your web app every time that there is new content on your website. Then the web app is activated by the push signal and downloads the new content in background, so that, as soon as the user opens the app, the new content is already available and can be displayed immediately.

However silent push is currently impossible, because browsers prevent that due to privacy concerns. To be more precise, most browsers expect that every time that a web push message is delivered to the app, a notification is displayed to the user... If you don't do that, then a default message is displayed to the user:

The website has refreshed in background

Depending on the browser, you may be able to send a few silent push messages without the user noticing that... The browser assumes that is just a temporary problem / exception. However if you use silent push several times, then this default notification will be certainly displayed. There is also a risk that your website gets a penalization.

This is to prevent websites from running in background, without the user knowing.

Yes... user has given consent to receive notifications, however if he never sees that your website is activated, then he may forget about it. In the meantime a malicious website could be activated frequently and consume bandwidth or track the user (e.g. location).

That is why web browsers want the user to know about web push and, although "silent push" has been discussed for long, it is not available at the moment.

It's interesting to note that when you try to subscribe a user to web push, by calling pushManager.subscribe() you must explicitly pass the option userVisibleOnly: true.

Finally there could be other cases where you may not want to display a notification to the user. For example, let's say that you have a chat on the website and you don't want to display the notification if the website is already opened... This is the only exception where silent push is allowed: when the website is already focused you can legitimately decide to drop the notification and not display it to the user. In this case there is also an alternative approach: instead of sending the notification and then dropping it, you can simply detect that the user is online on your website (e.g. using websocket heartbeats) and avoid sending the notification.