A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/ja/docs/Web/API/NotificationEvent/notification below:

NotificationEvent: notification プãƒãƒ‘ティ - Web API

NotificationEvent: notification プロパティ

Limited availability

メモ: この機能はサービスワーカー内でのみ利用可能です。

notification は NotificationEvent インターフェイスの読み取り専用プロパティで、クリックされてイベントを発行した Notification のインスタンスを返します。 Notification は tag や data 属性など、 Notification のインスタンス化時に設定された多くのプロパティへの読み取り専用アクセスを提供しており、あとで notificationclick イベントで使用するための情報を保存することができます。

返値

Notification オブジェクト。

例
self.addEventListener("notificationclick", (event) => {
  console.log("On notification click");

  // 通知にデータを添付することで、notificationclick ハンドラーで
  // 処理することができる
  console.log(`通知タグ: ${event.notification.tag}`);
  console.log(`通知データ: ${event.notification.data}`);
  event.notification.close();

  // これは、すでに開いているかどうかを調べて、開いている場合は
  // フォーカスする
  event.waitUntil(
    clients
      .matchAll({
        type: "window",
      })
      .then((clientList) => {
        for (const client of clientList) {
          if (client.url === "/" && "focus" in client) return client.focus();
        }
        if (clients.openWindow) return clients.openWindow("/");
      }),
  );
});
仕様書 ブラウザーの互換性

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4