let myNotification = "my-notification";
function toggleAlarm(all) {
if (myNotification in all) {
browser.notifications.clear(myNotification);
} else {
browser.notifications.create(myNotification, {
type: "basic",
iconUrl: browser.runtime.getURL("icons/cake-48.png"),
title: "Am imposing title",
message: "Some interesting content",
});
}
}
function handleClick() {
let gettingAll = browser.notifications.getAll();
gettingAll.then(toggleAlarm);
}
browser.browserAction.onClicked.addListener(handleClick);notifications.clear() / notebook
notifications.clear()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.