if ('serviceWorker' in navigator){
  window.addEventListener('load', function(){
    navigator.serviceWorker.register('/pwa/service-worker.js').then(function(reg){
      console.log('SW registered', reg);
    }).catch(function(err){ console.warn('SW reg failed', err); });
  });
}

navigator.serviceWorker.ready.then(sw => {
    if ('sync' in sw) {
        sw.sync.register('asolar-sync').catch(e=>{
            console.warn("Background sync disabled:", e);
        });
    }
});
