Skip to content

Notification popup doesn’t appear in chrome

I am trying to do a gmail similar type desktop notification . I am facing the difficulty to change the notification permission in chrome. The permission always shows denied in console if i use window.Notification.permission. If i manually change the permission in google chrome settings -> privacy -> content settings -> Notifications as “Allow all sites to show desktop notifications” from “Do not allow any site to show desktop notifications” . Now i am able to get desktop notification normally. But I need an alert to asking a permission if the browser have setting as “Do not allow any site to show desktop notifications” , then i need to choose allow from the popup in order to change the setting as “Allow all sites to show desktop notifications”. The problem is permission is not changed if i do like this even the permission alert is not coming . The permission checking script follows

if(Notification.permission == 'denied'){
                 Notification.requestPermission(function (status){
                        console.log("Reaching here");
                        Notification.permission = status;

The popup for requesting permission to allow or disallow notifications is not occurred. Thanks in advance for suggesting me a solution.



There seem to be a problem with your script.

It’s part of the standard that when the permission is set to denied you can NEVER show the popup which asks “Do you want to allow… to send desktop notifications ?”. This popup is used only in the case the permission is set to default, which in fact means that the user doesn’t care and you should ask him if he wants them or not.

This is the conditionnal I use :

Notification['permission'] !== 'granted' && Notification['permission'] !== 'denied'

Because the default value isn’t supported by all browsers. Plus the permission attribute was not implemented prior to chrome 32, that’s why you should access it using the square brackets.

In fact you could also remove the denied part in my conditionnal, because it won’t do anything if the permission is denied. You can refer to this MDN documentation to get more information on compatibility and things like that.

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