SyncManager: register() method
The SyncManager.register method of the SyncManager interface registers a synchronization event, triggering a sync event inside the associated service worker as soon as network connectivity is available.
Syntax
Parameters
-
tag
-
An identifier for this synchronization event. This will be the value of the tag property of the SyncEvent that gets passed into the service worker's sync event handler.
Return value
A Promise that resolves to undefined.
Examples
The following asynchronous function registers a background sync from a browsing context:
async function syncMessagesLater() {
const registration = await navigator.serviceWorker.ready;
try {
await registration.sync.register("sync-messages");
} catch {
console.log("Background Sync could not be registered!");
}
}
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
register |
49 |
79 |
No |
No |
36 |
No |
49 |
49 |
No |
36 |
No |
5.0 |