Tutorial by Examples

We use Notification.requestPermission to ask the user if he/she wants to receive notifications from our website. Notification.requestPermission(function() { if (Notification.permission === 'granted') { // user approved. // use of new Notification(...) syntax will now be succe...
After the user has approved a request for permission to send notifications, we can send a simple notification that says Hello to the user: new Notification('Hello', { body: 'Hello, world!', icon: 'url to an .ico image' }); This will send a notification like this: Hello Hello, world!
You can close a notification by using the .close() method. let notification = new Notification(title, options); // do some work, then close the notification notification.close() You can utilize the setTimeout function to auto-close the notification sometime in the future. let notification = n...
The Notification API specifications support 2 events that can be fired by a Notification. The click event. This event will run when you click on the notification body (excluding the closing X and the Notifications configuration button). Example: notification.onclick = function(event) { ...

Page 1 of 1