Initialize the Browser Notification
For more comfortable to use we need to take user permission to display web notification.
document.addEventListener('DOMContentLoaded', function () {
if (Notification.permission !== "granted")
{
Notification.requestPermission();
}
});
Push Notification
This function will help you to push notification data, here you have to update icon URL.Also you can pass title, description and Web URL.
if(window.Notification && Notification.permission !== "denied") {
Notification.requestPermission(function(status) { // status is "granted", if accepted by user
var n = new Notification('Title', {
body: 'I am the body text!',
icon: '/path/to/icon.png' // optional
});
});
}
Please share and Subscribe to get latest updates and tutorials form Being Idea
0 Comments