Created
January 10, 2017 18:56
-
-
Save RyannosaurusRex/8b21abe420c13a9b49681c91141b2b98 to your computer and use it in GitHub Desktop.
Example of how to send a notification using the Web Notification API
This file contains 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
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