[英]Push with Web Notifications API
I've just started looking at the Web Notifications API. 我刚刚开始查看Web Notifications API。 This JS will immediately display a notification when I load the page:
这个JS会在我加载页面时立即显示通知:
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. 每当有人(不是我)访问
customer.php
,通知应该显示给我,而不是他们。
Can this be done with the Web Notification API and if so, how would I go about it? 是否可以使用Web Notification API完成此操作,如果是这样,我将如何处理它?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.