BackgroundFetchManager.get()

Limited availability

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

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

get()BackgroundFetchManager インターフェイスのメソッドで、引数に与えられた id に紐づく BackgroundFetchRegistration で解決される Promise を返します。 id が見つからない場合は undefined を返します。

構文

js
get(id)

引数

id

fetch() を呼び出すことで定義された backgroundFetchRegistration の ID 。

返値

BackgroundFetchRegistration で解決される Promise または undefined

下記の例では、 get() を呼び出して BackgroundFetchRegistration を取得する方法を紹介しています。アクティブな service workerServiceWorkerRegistration.backgroundFetch を参照して BackgroundFetchManager オブジェクトにアクセスし、その get() メソッドを呼び出しています。

js
navigator.serviceWorker.ready.then(async (swReg) => {
  const bgFetch = await swReg.backgroundFetch.get("my-fetch");
});
// my code block

仕様書

Specification
Background Fetch
# background-fetch-manager-get

ブラウザーの互換性

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
get
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.