Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DOMException: Registration failed - permission denied

I have a web notification script which works fine. However when i was testing in chrome version 43, I get the error "DOMException: Registration failed - permission denied". This error occurs during the subscription stage.

Here's the code snippet which is the usual process of registration

navigator.serviceWorker.register('sw.js').then(function(reg) {
    console.log('[ServiceWorker] Registration Obj', reg);
    reg.pushManager.subscribe({
        userVisibleOnly: true
    }).then(function(sub) {
        //This never executes and catch gets called
        console.log('Subscription successful, Subscription endpoint:', sub.endpoint);
    }).catch(function(error) {
        console.log("Error during subscription ", error);
    });
}).catch(function(error) {
    if (Notification.permission === 'denied') {
        console.warn('Permission for Notifications was denied');
    } else {
        console.error('Unable to subscribe to push.', error);
    }
});

In the above code, the error occurs during the step where i do reg.pushManager.subscribe().

  • This doesn't happen in chrome 49.
  • This error always occurs on chrome version 43.

[Note] I assumed its a general problem with chrome version 43 but when i checked sites like goroost.com and pushcrew, they seem to be working fine. Only mine is not working

like image 465
Hari Krishnan Avatar asked Dec 05 '22 01:12

Hari Krishnan


1 Answers

I've encountered this problem. in addition to prajnavantha answers, this may be caused by accidentally clicking the browser notification when it block it or not. To fix this in Chrome, go to Settings->click 'Show Advanced Settings'->Under 'Privacy' click 'Content Settings'->Then under 'Notifications' select 'Manage Excpetions'. Once you're in here, allow the notification for the URL affected.

like image 196
MJ Convento Avatar answered Dec 24 '22 18:12

MJ Convento