BackgroundFetchManager: phương thức getIds()

Limited availability

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

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Note: This feature is available in Web Workers.

Phương thức getIds() của giao diện BackgroundFetchManager trả về mã nhận dạng của tất cả background fetch đã đăng ký.

Cú pháp

js
getIds()

Tham số

Không có.

Giá trị trả về

Một Promise được giải quyết bằng một Array các chuỗi.

Ngoại lệ

Không có.

Ví dụ

Ví dụ sau cho thấy cách truy xuất mã nhận dạng của tất cả background fetch đã đăng ký. Khi có một service worker đang hoạt động, hãy dùng thuộc tính ServiceWorkerRegistration.backgroundFetch để truy cập đối tượng BackgroundFetchManager và gọi phương thức getIds() của nó.

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

Thông số kỹ thuật

Specification
Background Fetch
# background-fetch-manager-get-ids

Khả năng tương thích trình duyệt