Skip to content

Instantly share code, notes, and snippets.

@catburston
Created August 4, 2014 12:59
Show Gist options
  • Save catburston/b7c39762ee54bda23aa2 to your computer and use it in GitHub Desktop.
Save catburston/b7c39762ee54bda23aa2 to your computer and use it in GitHub Desktop.
Notifications API
<button onclick="notifyMe()">click me</button>
function notifyMe() {
if (window.Notification) {
console.log("Browser supports notifications");
}
if (Notification.permission !== 'denied') {
Notification.requestPermission(function (permission) {
if (permission === 'granted') {
//var options = [];
var notification = new Notification("HIIIIII", {
icon: "http://www.lorempixel.com/90/90",
body: "Notification body goes here."
});
}
notification.onshow = function () {
setTimeout(notification.close, 100);
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment