WebPush: A page wants to send you notifications

Diese Seite gibt es auch in Deutsch

Apps have been able to do this for a long time, but the ability for websites to send notifications is somewhat newer. With the help of WebPush, users can be actively notified even if they are no longer on the corresponding website. The only requirement is that the browser is open.

Requirements

Receiving WebPush: the browser

No special apps are required to receive WebPush messages. WebPush is implemented directly in all new browsers. So-called service workers are responsible for the reception, these are activated when a notification is received, whereupon it is displayed .The service worker is a JavaScript file, which is provided by the web server and registered in the browser. To activate the corresponding service worker for a page, it is sufficient to grant permission for push notifications:

By allowing the notifications, a so-called subscription with the PushService is created via the Web Push API and the VAPID Key Pair (public and private key pair) provided by the web server.

PushService

The PushService is a service on the Internet, which is operated by the respective browser manufacturers for the conclusion of the subscription and the delivery of the messages.

Send WebPush: the web server

When the push notification is activated, an endpoint URL, a PublicKey and a token are generated using the VAPID Key Pairand a PushService operated by the browser manufacturer. The data is stored on the web server and can then be used by the website operator to create the notifications. In order for the service worker (browser) to receive messages from the PushService (Internet service of the browser manufacturer), these must first be encrypted at the web server with the private key of the VAPID pair.

Allow / disallow notifications

Permission to send notifications can be enabled or disabled at any time in the browser.
The web page notification settings are most easily accessed by clicking the lock icon to the left of the URL:

Firefox

Android

Google Chrome

The following URL can be used to display all service workers in Google Chrome:

chrome://serviceworker-internals/?devtools

WebPush provider vs. script

There are many providers on the internet that offer push notification services, but with the appropriate scripts the notification can be implemented without the need for an additional service provider: A demo implementation for Laravel can be examined on the following page: https://github.com/cretueusebiu/laravel-web-push-demo

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Publication: 2022-05-08 from Bernhard 🔔


Top articles in this section


Ping with Port | cmd vs. PowerShell: Test-Netconnection
As is well known, the tool ping can be used to test the access to a certain network device and its response time. Not all devices will respond to a ping, but they may respond to a particular Tcp-Port if a particular network service is provided through it. Windows PowerShell allows you to test a specific port using Windows board tools. The psping tool can also measure the response time to a specific port.

OpenWRT hardware recommendation - available devices 2022
OpenWRT provides a uniform and up-to-date software for different network devices like routers or access points and delivers countless additional setting options, software packages and functions. This makes it possible to combine new and old devices from different manufacturers and, among other things, to use low-cost hardware in a common WiFi, see: Setting up a home network: Extending LAN and WLAN | Improving.

List all IP addresses in the network even if the firewall is enabled
If you want to get a quick overview of all active devices in a network, you can do this with network discovery, commands in the command prompt, in PowerShell or with special IP scanners. The PowerShell commands presented at the beginning of this post give a quick overview of all devices on the local network and may make special programs for scanning the network unnecessary. If you would like to see the commands in action, you can do so in my YouTube video. For expanding your own network, see als...

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details