This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Note: This feature is only available in Service Workers.
The notificationclose event of the ServiceWorkerGlobalScope interface fires when a user closes a displayed notification spawned by ServiceWorkerRegistration.showNotification().
Notifications created on the main thread or in workers which aren't service workers using the Notification() constructor will instead receive a close event on the Notification object itself.
This event is not cancelable and does not bubble.
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("notificationclose", (event) => { })
onnotificationclose = (event) => { }
A NotificationEvent. Inherits from ExtendableEvent and Event.
Inherits properties from its ancestor, ExtendableEvent and Event.
NotificationEvent.notification Read only
Returns a Notification object representing the notification that was clicked to fire the event.
NotificationEvent.action Read only
Returns the string ID of the notification button the user clicked. This value returns an empty string if the user clicked the notification somewhere other than an action button, or the notification does not have a button.
// Inside a service worker.
self.onnotificationclose = (event) => {
console.log("On notification close: ", event.notification.tag);
};
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
notificationclose_event |
50 | 17 | 44 | 34 | 16Notifications are supported on macOS Ventura and later. |
50 | 44 | 34 | No | 5.0 | 50 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/notificationclose_event