BackgroundFetchEvent

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

Background Fetch APIBackgroundFetchEvent インターフェイスは、 service worker global scope で実行されるバックグラウンドのフェッチイベントのためのイベント型です。

これはイベント型で、onbackgroundfetchabort 、および、 onbackgroundfetchclick イベントハンドラープロパティに渡されます。

Event ExtendableEvent BackgroundFetchEvent

コンストラクター

BackgroundFetchEvent() Experimental

新規に BackgroundFetchEvent オブジェクトを作成します。通常、このコンストラクターが使用されることはありません。なぜなら、これらのオブジェクトはブラウザーによって自動で生成され、バックグラウンドのフェッチイベントのコールバックに渡されるからです。

プロパティ

祖先である Event のプロパティを継承します。

BackgroundFetchEvent.registration 読取専用 Experimental

イベントが初期化された BackgroundFetchRegistration を返します。

イベントハンドラー

なし。

メソッド

なし。

以下の例では、ユーザーがダウンロードの進捗表示のUIをクリックすると、新規にウィンドウが開きます。event.registration を呼び出して、現在の BackgroundFetchRegistration を取得しています。

js
addEventListener("backgroundfetchclick", (event) => {
  const bgFetch = event.registration;

  if (bgFetch.result === "success") {
    clients.openWindow("/latest-podcasts");
  } else {
    clients.openWindow("/download-progress");
  }
});

仕様書

Specification
Background Fetch
# background-fetch-event

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
BackgroundFetchEvent
Experimental
BackgroundFetchEvent() constructor
Experimental
registration
Experimental

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Experimental. Expect behavior to change in the future.