Básicamente, tengo un botón que, al hacer clic, activará una llamada a Notification.requestPermission y, según la respuesta de los usuarios, realizo alguna acción.
El problema es que Notification.requestPermission en realidad no se activa cuando Chrome lo bloquea automáticamente.
este es mi codigo
function askNotificationPermission(handler) { // checks to see if notification is actually supported function checkNotificationPromise() { try { // checks if promise based notification is okay Notification.requestPermission().then(); } catch(e) { return false; } return true; } // Let's check if the browser supports notifications if (!('Notification' in window)) { console.log("This browser does not support notifications."); } else { if(checkNotificationPromise()) { window.console.log("requesting permission...") Notification.requestPermission() .then((permission) => { window.console.log("PERMISSION", permission) handler(permission); window.console.log("finished handler") }) window.console.log("done", Notification.permission) } else { Notification.requestPermission(function(permission) { handler(permission); }); } } }¿Hay alguna forma de detectar cuándo las notificaciones se bloquean automáticamente?