Browser notifications triggered by the site

Recently, on some sites, I have seen that these browser levels trigger notifications that appear even if you did not open this website. You must enable the display of these notifications, and then they are almost ubiquitous, even when you first open a browser without tabs.

I do not know how to use these browser level notifications caused by my site. The name and some code examples would be appreciated, I don’t even know what programming language it is written in (assuming Javascript).

This is a screenshot of what I'm talking about (upper right corner):

notification 1

notification 2

notification 3

As you can see, they still appear, although the browser is minimized!

+8
javascript browser notifications
source share
3 answers

They are implemented using the Notification API - some recent documents can be found here:

https://developer.mozilla.org/en-US/docs/Web/API/notification

You can easily try it from the console of most modern browsers -

Notification.requestPermission(); 

Approve permission for notification, and then try

 new Notification('Hello, you have been notified!'); 

The documentation has more detailed usage examples.

+11
source share

As pvg said, there is an API browser called Notification that allows you to send notifications to your users. You must first ask for permission, and if granted , create a new Notification .

I built a micro library in javascript that exactly does this as an object, go here: https://github.com/jsmrcaga/miniNotif

The use is simple, you create a new notification as an object:

var yourNotif = new miniNotif.notification('title', {body: 'your body', icon: 'URL'});

and call yourNotif.show() whenever you want it to display.

I believe the readme on GitHub is deprecated, though

+2
source share

If you want to follow the usual notifications, the answers you received are correct.

If you want to implement PUSH notifications, the answer you expect is in this message (with an explanation and a tutorial explaining how you can implement it).

0
source share

All Articles