PeriodicSyncManager: getTags() メソッド

We’d love to hear your thoughts on the next set of proposals for the JavaScript language. You can find a description of the proposals here.
Please take two minutes to fill out our short survey.

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

getTags()PeriodicSyncManager インターフェイスのメソッドで、定期的な同期を行うために現在登録されているタグを表す String オブジェクトのリストで解決される Promise を返します。

構文

js
getTags()

引数

なし。

返値

定期的な同期を行うために現在登録されているタグを表す String オブジェクトのリストで解決される Promise です。

例外

なし。

次の例では、getTags() メソッドを使用して、指定されたタグを持つ定期的な同期タスクが登録されているかどうかを調べています。

js
navigator.serviceWorker.ready.then((registration) => {
  registration.periodicSync.getTags().then((tags) => {
    if (tags.includes("get-latest-news")) skipDownloadingLatestNewsOnPageLoad();
  });
});

skipDownloadingLatestNewsOnPageLoad() は開発者が定義した関数です。

仕様書

Specification
Web Periodic Background Synchronization
# dom-periodicsyncmanager-gettags

ブラウザーの互換性

関連情報