Skip to content

Instantly share code, notes, and snippets.

@balajek
Created April 5, 2018 11:21
Show Gist options
  • Save balajek/a3c20091a669df05aeee26ac82807c9a to your computer and use it in GitHub Desktop.
Save balajek/a3c20091a669df05aeee26ac82807c9a to your computer and use it in GitHub Desktop.
Adding event listeners for notifications
// Add listener for onClicked event.
browser.notifications.onClicked.addListener(function (notificationid) {
window.alert(notificationid + " clicked");
});
// Add listener for onButtonClicked event.
browser.notifications.onButtonClicked.addListener(function (notificationid, buttonIndex) {
window.alert("Button " + buttonIndex + " of " + notificationid + " clicked");
});
// Add listener for onClosed event.
browser.notifications.onClosed.addListener(function (notificationid, byUser) {
window.alert("Notification " + notificationid + " closed " + (byUser ? "by user" : "automatically due to timeout"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment