ServiceWorkerGlobalScope: notificationclose イベント
        
        
          Limited availability
        
        
        
          
                
              
                
              
                
              
        
        
      
      This feature is not Baseline because it does not work in some of the most widely-used browsers.
安全なコンテキスト用: この機能は一部またはすべての対応しているブラウザーにおいて、安全なコンテキスト (HTTPS) でのみ利用できます。
メモ: この機能はサービスワーカー内でのみ利用可能です。
notificationclose は ServiceWorkerGlobalScope インターフェイスのイベントで、ServiceWorkerRegistration.showNotification() によって生成された表示中の通知をユーザーが閉じたときに発生します。
メインスレッドや、サービスワーカー以外のワーカーが Notification() コンストラクターを使用して生成した通知では、close イベントを Notification オブジェクト自身が受け取ります。
このイベントはキャンセル不可で、バブリングしません。
構文
このイベント名を addEventListener() 等のメソッドで使用するか、イベントハンドラープロパティを設定するかしてください。
addEventListener("notificationclose", (event) => {});
onnotificationclose = (event) => {};
イベント型
NotificationEvent です。ExtendableEvent および Event を継承しています。
イベントプロパティ
祖先である ExtendableEvent および Event から継承したプロパティがあります。
- NotificationEvent.notification読取専用
- 
クリックされイベントが発行された通知を表す Notificationオブジェクトを返します。
- NotificationEvent.action読取専用
- 
ユーザーがクリックした通知ボタンの文字列 ID を返します。この値は、ユーザーがアクションボタン以外のどこかで通知をクリックした場合、またはその通知にボタンがなかった場合、空文字列を返します。 
例
// サービスワーカーの内部で
self.onnotificationclose = (event) => {
  console.log("On notification close: ", event.notification.tag);
};
仕様書
| Specification | 
|---|
| Notifications API> # dom-serviceworkerglobalscope-onnotificationclose> | 
ブラウザーの互換性
Loading…