Created
December 1, 2020 14:39
-
-
Save devpato/479a2d11887424dea048ac25e26a9370 to your computer and use it in GitHub Desktop.
Notification API
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
<button onclick="notifyMe()">Notify me!</button> | |
<script> | |
function notifyMe() { | |
//TO TEST THIS CODE CLICK ON THE UPPER RIGHT CORNER WHERE IT SAYS "OPEN IN NEW WINDOW" | |
if (!("Notification" in window)) { | |
alert("This browser does not support desktop notification"); | |
} else if (Notification.permission === "granted") { | |
const notification = new Notification("Hi This Dot Labs!"); | |
} | |
else if (Notification.permission !== "denied") { | |
Notification.requestPermission().then(function(permission) { | |
if (permission === "granted") { | |
const notification = new Notification("Hi This Dot Labs!"); | |
} | |
}); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment