In my coding work, I rely on Notification.permission
to determine if the browser supports notifications or not. Here's a snippet of how I handle Notification.permission
in my script:
// Verify browser notification support
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
var prm = Notification.permission;
if (prm == 'default' || prm == 'denied') {
console.log("Permission denied or default");
} else {
console.log("Permission granted");
}
While this code operates smoothly on my localhost
, in a production environment, it consistently displays a 'denied' status. My browser notification settings are configured to 'always allow on this site'.
https://i.sstatic.net/cMuAQ.png
I am currently stumped by this issue and unable to pinpoint the cause.