Created
June 28, 2023 13:19
-
-
Save jorgevilaca82/2a3816b63f90a23779b5e9e4ab489169 to your computer and use it in GitHub Desktop.
This file contains 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 requestNotificationPermission() { | |
Notification.requestPermission().then(p => { | |
if (p === "granted") { | |
console.log("Thank you") | |
} else { | |
console.log("😔") | |
} | |
}).catch(function (err) { | |
console.log(err) | |
}) | |
} | |
function notifyMe(title, options) { | |
if (window.Notification && Notification.permission === "granted") { | |
new Notification(title, options) | |
} | |
else { | |
requestNotificationPermission() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment