Created
June 17, 2019 03:54
-
-
Save tkssharma/57c0afde85dd0a0cd7ad8731f318727b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import App from './App'; | |
ReactDOM.render(<App />, document.getElementById('root')); | |
if (window.navigator && navigator.serviceWorker) { | |
navigator.serviceWorker.getRegistrations() | |
.then(function (registrations) { | |
const promise = []; | |
for (let registration of registrations) { | |
promise.push(registration.unregister()); | |
} | |
return Promise.all(promise); | |
}).then((data) => { | |
navigator.serviceWorker.register('service-worker.js').then(function (registration) { | |
// Registration Success | |
console.log(registration); | |
console.log('[serviceWorker]: registration successful with scope: ', registration.scope + 'for env ' + process.env.PUBLIC_URL); | |
}).catch(function (err) { | |
// Registration failed :( | |
console.log('[serviceWorker] registration failed', err); | |
}); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment