6

I'm testing HTML5 notifications on localhost, with SSL. I've reset the Chrome settings for the site (by clicking the lock icon in the URL box - "site settings"), and double checked notification setting is set to "Ask (default)".

Now here's my code:

if (Notification.permission !== "granted") {
    Notification.requestPermission();
}

But once the code is run, no permissions popup is displayed, instead I get this lock icon in the address bar that says "Notifications blocked":

enter image description here

Tried adding .then() promise to the code - same result. Using Chrome Version 85.0.4183.102. Did they change something?

I do see blog posts mentioning that Chrome disables notifications automatically if the user closed the popup three times, But I did reset the settings did I?

P.S. If I refresh the page and request the permissions again - I see this in the console "Notifications permission has been blocked as the user has ignored the permission prompt several times." Wait, how could I ignore the prompt if I haven't even seen it?

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149

1 Answers1

4

Ok, so after an hour of banging my head against the wall, I found the reason.

enter image description here

That little lock icon in the address bar - is the new "notification prompt" ladies and gentlemen.

That's... disappointing

P.S. We all understand the intention behind this is to prevent people from abusing these popups. But a better way would be to check, if the code runs in the user-triggered context (e.g. in response to a click) and if so - leave it like before.

Alex from Jitbit
  • 53,710
  • 19
  • 160
  • 149
  • Maybe rather address your “FFS” at the developers who made this kind of action necessary in the first place :-) – CBroe Sep 18 '20 at 11:25
  • @CBroe touche, I see your point. But it feels like legitimate developers are paying for the actions of a limited group of spammers. We are developing an B2B app that's not accessible from the public Internet :( – Alex from Jitbit Sep 18 '20 at 11:37
  • _“But it feels like legitimate developers are paying for the actions of a limited group of spammers.”_ - yes, but isn’t that always the case? Browser vendors are playing catch-up with restricting a lot of things, that _have_ legitimate applications, but simply get abused too often, think autoplay of videos with sound for example. – CBroe Sep 18 '20 at 11:42