Created
July 4, 2020 00:57
-
-
Save ottino/963dba7ba53e4b9a599f6e53e9006cec to your computer and use it in GitHub Desktop.
sw: Ejemplo para solicitud de envio de notificaciones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function notificarme() { | |
| if ( !window.Notification ) { | |
| console.log('Este navegador no soporta notificaciones!'); | |
| return; | |
| } | |
| // Si se le pregunto con anterioridad si | |
| // desea recibir notificaciones | |
| if ( Notification.permission === 'granted' ) { | |
| new Notification('Hola!! - granted'); | |
| } // No se a negado | |
| else if ( Notification.permission !== 'denied' || | |
| Notification.permission === 'default' ) { | |
| // Realizar la solicitud al usuario | |
| Notification.requestPermission( function ( permission ) { | |
| console.log( permission ); | |
| if ( permission === 'granted' ){ | |
| new Notification('Hola!! - desde la pregunta!'); | |
| } | |
| }); | |
| } | |
| } | |
| notificarme(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment