Last active
August 30, 2017 20:46
-
-
Save webmaxru/7dc8b51ee2b931f3a9a1b110e335a6c9 to your computer and use it in GitHub Desktop.
This file contains 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
platformBrowserDynamic() | |
.bootstrapModule(AppModule) | |
.then(() => { | |
registerServiceWorker('sw-default') | |
}); | |
function registerServiceWorker(swName: string) { | |
if ('serviceWorker' in navigator) { | |
navigator.serviceWorker | |
.register(`/${swName}.js`) | |
.then(reg => { | |
console.log('[App] Successful service worker registration', reg); | |
}) | |
.catch(err => | |
console.error('[App] Service worker registration failed', err) | |
); | |
} else { | |
console.error('[App] Service Worker API is not supported in current browser'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment