我无法检测用户是否取消或关闭了推送通知。
这是我编写的显示推送通知的代码
// JS Nuggets: Notifications API
//Notification.requestPermission();
//new Notification("Subscribe to JS Nuggets!");
function notifyMe() {
if (!("Notification" in window)) {
alert("This browser does not support system notifications");
}
else if (Notification.permission === "granted") {
notify();
}
else if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === "granted") {
notify();
}
});
}
function notify() {
var notification = new Notification('TITLE OF NOTIFICATION', {
icon: 'http://carnes.cc/jsnuggets_avatar.jpg',
body: "Hey! You are on notice!",
});
notification.onclick = function () {
window.open("http://carnes.cc");
};
setTimeout(notification.close.bind(notification), 7000);
}
}
notifyMe();
我会在截止日期前结束,因此,非常感谢您的帮助:)
谢谢
阿纳夫