btn.addEventListener("click", () => {
let promise = Notification.requestPermission();
// wait for permission
});Notifications API / notebook
Notifications API
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
if (Notification.permission === "granted") {
const notification = new Notification("New message from Alice", {
body: "Hey, are you free for lunch?",
navigate: "/messages/alice",
});
}