1
在允許通知時,我遇到了帶有Web通知的Firefox問題,但沒有記住選擇。請參閱圖像如何在允許但不記住Firefox中的選擇時顯示Web通知?
每當用戶允許的通知,會出現問題,但不會讓火狐記得的決定。每當用戶堅持做出決定時,通知就會顯示得很好。
// 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(),無論選擇是否被記住。該權限總是等於「授予」。但是,當選擇被記住時創建通知時,通知會顯示。當不記得時,代碼執行得很好(包括創建通知),但沒有通知顯示。任何猜測?