https://github.com/alexgibson/notify.js
To initialize a web notification create a new Notify instance, passing the message title as well as any other options you wish to use.
Notify
title
var myNotification = new Notify('Yo dawg!', { body: 'This is an awesome notification', notifyShow: onNotifyShow }); function onNotifyShow() { console.log('notification was shown!'); }
Then show the notification.
myNotification.show();
It's a good idea to make sure that you have permissions to send notifications first.
if (!Notify.needsPermission) { doNotification(); } else if (Notify.isSupported()) { Notify.requestPermission(onPermissionGranted, onPermissionDenied); } function onPermissionGranted() { console.log('Permission has been granted by the user'); doNotification(); } function onPermissionDenied() { console.warn('Permission has been denied by the user'); }