* Registers a sync event with a tag unique to this instance.
()
| 391 | * Registers a sync event with a tag unique to this instance. |
| 392 | */ |
| 393 | async registerSync(): Promise<void> { |
| 394 | // See https://github.com/GoogleChrome/workbox/issues/2393 |
| 395 | if ('sync' in self.registration && !this._forceSyncFallback) { |
| 396 | try { |
| 397 | await self.registration.sync.register(`${TAG_PREFIX}:${this._name}`); |
| 398 | } catch (err) { |
| 399 | // This means the registration failed for some reason, possibly due to |
| 400 | // the user disabling it. |
| 401 | if (process.env.NODE_ENV !== 'production') { |
| 402 | logger.warn( |
| 403 | `Unable to register sync event for '${this._name}'.`, |
| 404 | err, |
| 405 | ); |
| 406 | } |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * In sync-supporting browsers, this adds a listener for the sync event. |
no test coverage detected