I've just started looking at the Web Notifications API. This JS will immediately display a notification when I load the page:
if("Notification" in window) {
if(Notification.permission == "granted") {
var notification = new Notification("Notification Title", {"body":"Message Body", "icon":"my-icon.png"});
} else {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
var notification = new Notification("Notification Title", {"body":"Message Body", "icon":"my-icon.png"});
}
});
}
} else {
alert("Your browser doesn't support notifications");
}
But what I am more interested in is having the notification displayed to me when someone else visits the same page. Whenever someone (not me) visits customer.php
for example, the notification should show for me, not them.
Can this be done with the Web Notification API and if so, how would I go about it?