如何在允许但不记住 Firefox 中的选择时显示网络通知?
How to show web notification when allowing but not remembering choice in Firefox?
我 运行 在允许通知但不记得选择的情况下在 Firefox 上使用 Web 通知遇到问题。请看图
只要用户允许通知,但不让 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(),无论选择是否被记住。权限始终等于 "granted"。但是,在记住选择时创建通知时,会显示通知。当不记得时,代码执行得很好(包括通知的创建)但不显示通知。有什么猜测吗?
事实证明,这是一个错误,参见 Bugzilla
我 运行 在允许通知但不记得选择的情况下在 Firefox 上使用 Web 通知遇到问题。请看图
只要用户允许通知,但不让 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(),无论选择是否被记住。权限始终等于 "granted"。但是,在记住选择时创建通知时,会显示通知。当不记得时,代码执行得很好(包括通知的创建)但不显示通知。有什么猜测吗?
事实证明,这是一个错误,参见 Bugzilla