Skip to content

Instantly share code, notes, and snippets.

@jorgevilaca82
Created June 28, 2023 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgevilaca82/2a3816b63f90a23779b5e9e4ab489169 to your computer and use it in GitHub Desktop.
Save jorgevilaca82/2a3816b63f90a23779b5e9e4ab489169 to your computer and use it in GitHub Desktop.
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