ServiceWorkerRegistration: thuộc tính periodicSync

Khả dụng hạn chế

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.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

Thuộc tính chỉ đọc periodicSync của giao diện ServiceWorkerRegistration trả về một tham chiếu đến giao diện PeriodicSyncManager, cho phép đăng ký các tác vụ chạy ở các khoảng thời gian cụ thể.

Giá trị

Một đối tượng PeriodicSyncManager.

Ví dụ

Bạn có thể truy cập thuộc tính từ tập lệnh chính hoặc service worker đã đăng ký.

Đây là một ví dụ từ tập lệnh chính:

js
// reference registration
const registration = await navigator.serviceWorker.ready;

// feature detection
if ("periodicSync" in registration) {
  // Background Periodic Sync functionality
  const periodicSync = registration.periodicSync;
}

Từ service worker:

js
// service worker script

const periodicSync = self.registration.periodicSync;

Đặc tả kỹ thuật

Thông số kỹ thuật
Web Periodic Background Synchronization
# dom-serviceworkerregistration-periodicsync

Tương thích trình duyệt

Xem thêm