Skip to content
Advertisement

Resetting denied HTML notifications

I have a web app in which I am using HTML Notifications. It works fine if the user allows it for the first time and start using it, however if user blocks the notification the first time by clicking the block button and later on try to request permission again by some user gesture then the browser doesn’t trigger (Allow/Block) popup.

Here is the second time I am triggering the permission.

if(Notification.permission == 'denied' || Notification.permission == 'default'){

        Notification.requestPermission(function (permission) {
    // If the user accepts, let's create a notification
            if (permission === "granted") {
                console.log("Regranted");
            }
        });
    }

It works fine for the default case but not for the denied case.

Advertisement

Answer

The behavior you’re seeing is by design, as an earlier comment points out. If you read step 2, substep 2 at https://notifications.spec.whatwg.org/#dom-notification-requestpermission you’ll see the spec requires that the only time a user is asked whether showing notifications is acceptable is when the permission value is default. If the permission value is granted or blocked, that algorithm requires that the user is never asked again whether showing notifications is acceptable.

Users who do change their minds about notifications for a site they’ve blocked have the option to go into their browser settings to reset the permissions for that site themselves.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement