Skip to content

Instantly share code, notes, and snippets.

@RyannosaurusRex
Created January 10, 2017 18:56
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 RyannosaurusRex/8b21abe420c13a9b49681c91141b2b98 to your computer and use it in GitHub Desktop.
Save RyannosaurusRex/8b21abe420c13a9b49681c91141b2b98 to your computer and use it in GitHub Desktop.
Example of how to send a notification using the Web Notification API
function showNotification(title, body) {
var notification = new Notification(title, { body });
notification.onclick = e => {
alert("Clicked!");
};
}
Notification.requestPermission(permission => {
console.log(permission);
if(permission==="granted") {
var t = "Hello there!";
var m = "Message using the Web Notification API.";
showNotification(t,m);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment