Back to Content

BackgroundFetchManager: getIds() method

files/en-us/web/api/backgroundfetchmanager/getids/index.md

latest938 B
Original Source

{{APIRef("Background Fetch API")}}{{SeeCompatTable}}{{AvailableInWorkers}}

The getIds() method of the {{domxref("BackgroundFetchManager")}} interface returns the IDs of all registered background fetches.

Syntax

js-nolint
getIds()

Parameters

None.

Return value

A {{jsxref("Promise")}} that resolves with an {{jsxref('Array')}} of {{jsxref('String', 'strings')}}.

Exceptions

None.

Examples

The following examples shows how to retrieve the IDs of all registered background fetches. With an active service worker, use the {{domxref('ServiceWorkerRegistration.backgroundFetch')}} property to access the BackgroundFetchManager object and call its getIds() method.

js
navigator.serviceWorker.ready.then(async (swReg) => {
  const ids = await swReg.backgroundFetch.getIds();
});

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}