Skip to content

Instantly share code, notes, and snippets.

@ViniciusAugusto
Last active June 22, 2017 17:52
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 ViniciusAugusto/8c0a5b14552e68aec361c7b4f3ef43cf to your computer and use it in GitHub Desktop.
Save ViniciusAugusto/8c0a5b14552e68aec361c7b4f3ef43cf to your computer and use it in GitHub Desktop.
Web Notification
document.addEventListener('DOMContentLoaded', function () {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}
if (Notification.permission !== "granted")
Notification.requestPermission();
});
function notifyMe() {
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Notification title', {
icon: 'https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png',
body: "Web Notification content",
});
notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment