Search code examples
firefoxweb-notifications

How to show web notification when allowing but not remembering choice in Firefox?


I have run into a problem on Firefox with web notifications when allowing notifications, but not remembering the choice. Please see image

here

The problem occurs whenever the user allows notifications, but doesn't let Firefox remember the decision. Whenever the user does persist the decision, the notification shows just fine.

// 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();
        }
    });
}

Here is the code I'm running for this notification. When the user allows the notification, the code always gets to the second createNotification(), whether the choice was remembered or not. The permission is always equal to "granted". However, when creating the notification when the choice is remembered, the notification shows. When not remembering, the code executes just fine (including the creation of the notification) but no notification is displayed. Any guesses?


Solution

  • Turns out, this is a bug, see Bugzilla