Hi i want to send desktop notifications to guest which is visited my web site.
So i need to use Chrome apis for this. Because only chrome browser has the desktop notification.
Here is my Codes to send notification. I checked out this Chrome Desktop Notification Example
function notifyMe() {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
var notification = new Notification("Hi there!");
}
// Otherwise, we need to ask the user for permission
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
// If the user accepts, let's create a notification
if (permission === "granted") {
var notification = new Notification("Hi there!");
}
});
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="check.js"></script>
</head>
<body>
<input type="button" onclick="notifyMe()" value="Send Notification"></input>
</body>
</html>
When i clicked the button a notification appears just for me. But i want to make an admin panel and when i clicked the button that notification should be appear for all users who visited my web site and allow for notification. For example in the May 21 i need to send notification like "Today is May 21 you can get cheap stuffs !" This message must be appear for all users who allowed for notifications. Thank you.