Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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