允许通知时,我在 Firefox 上遇到了网络通知问题,但不记得选择。请看图片
每当用户允许通知但不让 Firefox 记住该决定时,就会出现问题。每当用户确实坚持该决定时,通知就会显示得很好。
// Let's check whether notification permissions have already been granted
if (Notification.permission === "granted") {
// If it's okay let's create a notification
createNotification();
}
// 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") {
createNotification();
}
});
}
这是我为此通知运行的代码。当用户允许通知时,无论选择是否被记住,代码总是会到达第二个 createNotification()。权限始终等于“已授予”。但是,在记住选择时创建通知时,会显示通知。不记得时,代码执行得很好(包括创建通知),但不显示通知。有什么猜测吗?
