Closing a notification
suggest changeYou can close a notification by using the .close()
method.
let notification = new Notification(title, options);
// do some work, then close the notification
notification.close()
You can utilize the setTimeout
function to auto-close the notification sometime in the future.
let notification = new Notification(title, options);
setTimeout(() => {
notification.close()
}, 4000);
The above code will spawn a notification and close it after 4 seconds.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents