Notification.requestPermission() not requesting permission
11,441
This works:
Notification.requestPermission().then(function(permission) { console.log('permiss', permission)});
Function inside .then()
is already a resolve-handler to the promise initiated by requestPermission()
.
Browsers save your decision for the particular domain and will not ask for your permission again.
For them to ask again you would have to make them forget your last decision. This is how you can do it in Firefox:
Delete the permission here and reload the page for the browser to ask you again.
Related videos on Youtube
Author by
unixcorn
Updated on June 04, 2022Comments
-
unixcorn almost 2 years
The browser keeps forgoing to ask permission for notifications and just decides it's on default. How do I get it to ask for permission so I can actually accept?
-
unixcorn about 5 yearsThank you for such a quick response; I still don't get a request. All that gets printed on my console is "Webconsole context has changed \n permiss default"
-
YetAnotherBot about 5 yearswhich browser ?
-
YetAnotherBot about 5 yearsAlso, could you please paste the above code directly in the browser console and test? It works for me.
-
unixcorn about 5 yearsIt's firefox. I just tried it and I get: > Promise { <state>: "pending} \n permiss default. No request for notification permissions whatsoever :(
-
YetAnotherBot about 5 yearsI just tried this. After fiddling around it seems browsers remember your decision and resolve your request on past decisions.
-
unixcorn about 5 yearsThe jsfiddle definitely works, in both chrome and firefox (this is for a firefox addon). The thing is, my addon still doesn't fire up a request. I got rid of 'window' and the console doesn't even print 'perm granted'. Just 'Webconsole context has changed'. Thank you for the help.
-
unixcorn about 5 yearsI just tried adding another console.log statement before 'console.log('Perm granted', getperm). This console.log statement doesn't even get printed. I think I'm simply not entering the function.
-
unixcorn about 5 yearsI thought so too, and reset firefox. I decided to post on SO after even that didn't work. Any suggestions?
-
YetAnotherBot about 5 yearsCheck the latest answer.