Tuesday 14 January 2020

Background sync in Service Worker is not working in chrome on android

I have added PWA to an angular application.

Below is the code inside the service worker, which listen to the sync event. Once service worker detects internet connection it triggers this sync event.

self.addEventListener('sync', function (event) {
 console.log('syncing started.');
event.waitUntil(getAllrecordsAndPost());
});

In component:

Sync event registration:

navigator.serviceWorker.ready.then(function(swRegistration) {
      return swRegistration.sync.register('myFirstSync');
    });

This is working fine in the chrome at the desktop, but on the android chrome, background sync event is not working.

FYI: I am using latest chrome version (79).



from Background sync in Service Worker is not working in chrome on android

No comments:

Post a Comment