Include scope fix for service worker as shown: https://stackoverflow.com/questions/46541071/progressive-web-app-does-not-work-offline-error
This commit is contained in:
@@ -14,14 +14,14 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Initialize the service worker
|
// Initialize the service worker
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
window.addEventListener('load', function () {
|
navigator.serviceWorker.register('/serviceworker.js', {
|
||||||
navigator.serviceWorker.register('/serviceworker.js').then(function (registration) {
|
scope: '.' // <--- THIS BIT IS REQUIRED
|
||||||
|
}).then(function (registration) {
|
||||||
// Registration was successful
|
// Registration was successful
|
||||||
console.log('django-progressive-web-app: ServiceWorker registration successful with scope: ', registration.scope);
|
console.log('django-progressive-web-app: ServiceWorker registration successful with scope: ', registration.scope);
|
||||||
}).catch(function (err) {
|
}, function (err) {
|
||||||
// registration failed :(
|
// registration failed :(
|
||||||
console.log('django-progressive-web-app: ServiceWorker registration failed: ', err);
|
console.log('django-progressive-web-app: ServiceWorker registration failed: ', err);
|
||||||
});
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user