admin管理员组文章数量:1390618
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":
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?
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":
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?
1 Answer
Reset to default 6Ok, so after an hour of banging my head against the wall, I found the reason.
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.
本文标签:
版权声明:本文标题:javascript - Notification.requestPermissions - no dialog shown, "automatically blocked" message in Chrome - St 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744621520a2616054.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论