How can I get notifications from the websites I have made using HTML?

Hi, can anyone please suggest how can I get notifications from the websites I have made using HTML? Pleaese help.

I have not much idea about it, however a bit of research led me to the following result:

It begins with a basic HTML5 boilerplate with CDN for jQuery and PubNub.

Then, inside the body tag, we added a button calling a JavaScript function to test the Notification functionality.

Notify me!

Here is how the notifyMe function looks like:

function notifyMe(message) {
if (message == undefined) {
message = "Hi there! You clicked a button.";
};

Here it checks if the function is getting any parameters. If not, we are setting a message as on clicking the button no message is being passed.

if (!("Notification" in window)) {
 alert("This browser does not support desktop notification");
 }
else if (Notification.permission === "granted") {
 var notification = new Notification(message);
 }
else if (Notification.permission !== 'denied') {
 Notification.requestPermission(function (permission) {
 if (permission === "granted") {
 var notification = new Notification("Hi there!");
 }
 });
 }

This block checks if the browser supports notifications. If it supports, then we check whether notification permissions have already been granted. If not, we need to ask the user for permission. If they allow, then we are good to go to create notifications and we pass the message parameters to the notification.

So we have a basic our HTML5 notification API working. Now we need to get the messages from PubNub’s channel and pass it to notification API to make these notifications really realtime.

$(document).ready(function() {
var pubnub = PUBNUB({
 subscribe_key : 'demo'
 });
pubnub.subscribe({
 channel : "pubnub-html5-notification-demo", // Subscribing to PubNub's channel
 message : function(message){
 console.log(message);
 notifyMe(message.text);
 }
 })
});

Firstly, as soon as the document or HTML page is loaded, we are initializing the PubNub using before mentioned CDN. We instantiate with a subscribe key as only subscribe_key is needed if there is no publishing to channel. Then we are telling to subscribe to “pubnub-html5-notification-demo” channel, and whatever message comes through it, pass it to notifyMe function as parameter.