files/en-us/web/api/serviceworkerglobalscope/notificationclose_event/index.md
{{APIRef("Web Notifications")}}{{SecureContext_Header}}{{AvailableInWorkers("service")}}
The notificationclose event of the {{domxref("ServiceWorkerGlobalScope")}} interface fires when a user closes a displayed notification spawned by {{domxref("ServiceWorkerRegistration.showNotification()")}}.
Notifications created on the main thread or in workers which aren't service workers using the {{domxref("Notification.Notification","Notification()")}} constructor will instead receive a {{domxref("Notification/close_event", "close")}} event on the {{domxref("Notification")}} object itself.
This event is not cancelable and does not bubble.
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
addEventListener("notificationclose", (event) => { })
onnotificationclose = (event) => { }
A {{domxref("NotificationEvent")}}. Inherits from {{domxref("ExtendableEvent")}} and {{domxref("Event")}}.
{{InheritanceDiagram("NotificationEvent")}}
Inherits properties from its ancestor, {{domxref("ExtendableEvent")}} and {{domxref("Event")}}.
// Inside a service worker.
self.onnotificationclose = (event) => {
console.log("On notification close: ", event.notification.tag);
};
{{Specifications}}
{{Compat}}