PeriodicSyncManager
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.
The PeriodicSyncManager interface of the Web Periodic Background Synchronization API provides a way to register tasks to be run in a service worker at periodic intervals with network connectivity. These tasks are referred to as periodic background sync requests. Access PeriodicSyncManager through the ServiceWorkerRegistration.periodicSync.
Instance properties
None.
Instance methods
PeriodicSyncManager.register()Experimental-
Registers a periodic sync request with the browser with the specified tag and options. Returns a
Promisethat resolves when the registration completes. -
Returns a
Promisethat resolves with a list ofstringsrepresenting the tags that are currently registered for periodic syncing. PeriodicSyncManager.unregister()Experimental-
Unregisters the periodic sync request corresponding to the specified tag and returns a
Promisethat resolves when unregistration completes.
Examples
The following examples show how to use the interface.
Requesting a Periodic Background Sync
The following asynchronous function registers a periodic background sync at a minimum interval of one day from a browsing context:
Verifying a Background Periodic Sync by Tag
This code checks to see if a Periodic Background Sync task with a given tag is registered.
Removing a Periodic Background Sync Task
The following code removes a Periodic Background Sync task to stop articles syncing in the background.
Specifications
| Specification |
|---|
| Web Periodic Background Synchronization # periodicsyncmanager-interface |