我想将推送发送到firefox网络浏览器.......
<script>
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!");
}
});
}
// At last, if the user has denied notifications, and you
// want to be respectful there is no need to bother them any more.
} Notification.requestPermission().then(function (result) {
console.log(result);
}); function spawnNotification(theBody, theIcon, theTitle) {
var options = {
body: theBody,
icon: theIcon
}
var n = new Notification(theTitle, options);
}
</script>
每当我的网站第一次运行权限时,弹出窗口就会出现。但是当用户点击允许按钮时如何获取像id这样的浏览器信息。我想将该浏览器ID保存到我的数据库中。下次我将使用该ID发送通知。我没有找到任何代码请帮助我。请任何人帮助我。
答案 0 :(得分:0)
Web Notifications API没有按照它的想法行事。
它只能用于显示用户当前在其浏览器中打开的网页的通知。它与alert()
相当,但有更多种格式选项。
不推送通知服务,不能用作推送通知服务。