我正在尝试实现我的桌面通知的网络视图。在桌面应用程序中,我已经使用以下Javascript代码实现了桌面通知的使用
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.
}
当我在android应用程序中打开视图时,显示警告,表明该设备不支持桌面通知。但是,使用移动浏览器(Chrome),此代码使我允许请求通知,但无法在桌面界面中给我相同的通知。非常感谢:)