Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. ServiceWorkerGlobalScope
  4. notificationclose

ServiceWorkerGlobalScope: notificationclose event

Limited availability

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 insecure contexts (HTTPS), in some or allsupporting browsers.

Note: This feature is only available inService Workers.

Thenotificationclose event of theServiceWorkerGlobalScope interface fires when a user closes a displayed notification spawned byServiceWorkerRegistration.showNotification().

Notifications created on the main thread or in workers which aren't service workersusing theNotification() constructor willinstead receive aclose event on theNotification objectitself.

This event is not cancelable and does not bubble.

Syntax

Use the event name in methods likeaddEventListener(), or set an event handler property.

js
addEventListener("notificationclose", (event) => { })onnotificationclose = (event) => { }

Event type

ANotificationEvent. Inherits fromExtendableEvent andEvent.

Event ExtendableEvent NotificationEvent

Event properties

Inherits properties from its ancestor,ExtendableEvent andEvent.

NotificationEvent.notificationRead only

Returns aNotification object representing the notification that was clicked to fire the event.

NotificationEvent.actionRead 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.

Example

js
// Inside a service worker.self.onnotificationclose = (event) => {  console.log("On notification close: ", event.notification.tag);};

Specifications

Specification
Notifications API
# dom-serviceworkerglobalscope-onnotificationclose

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp