let cakeNotification = "cake-notification";
/*
CAKE_INTERVAL is set to 6 seconds in this example.
Such a short period is chosen to make the extension's behavior
more obvious, but this is not recommended in real life.
Note that in Chrome, alarms cannot be set for less
than a minute.
*/
let CAKE_INTERVAL = 0.1;
browser.alarms.create("", { periodInMinutes: CAKE_INTERVAL });
browser.alarms.onAlarm.addListener((alarm) => {
browser.notifications.create(cakeNotification, {
type: "basic",
iconUrl: browser.runtime.getURL("icons/cake-96.png"),
title: "Time for cake!",
message: "Something something cake",
});
});
browser.browserAction.onClicked.addListener(() => {
const clearing = browser.notifications.clear(cakeNotification);
clearing.then(() => {
console.log("cleared");
});
});notifications.create() / notebook
notifications.create()
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.