2021-02-22 02:39:04 +00:00
|
|
|
import { register } from "register-service-worker";
|
2020-09-10 16:39:01 +00:00
|
|
|
|
2021-02-22 02:39:04 +00:00
|
|
|
register("/service-worker.js", {
|
|
|
|
registrationOptions: { scope: "./" },
|
2021-02-22 02:24:09 +00:00
|
|
|
ready() {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.log("Service worker is active.");
|
2021-01-24 18:52:52 +00:00
|
|
|
},
|
2021-02-22 02:24:09 +00:00
|
|
|
registered() {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.log("Service worker has been registered.");
|
2021-01-24 18:52:52 +00:00
|
|
|
},
|
2021-02-22 02:24:09 +00:00
|
|
|
cached() {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.log("Content has been cached for offline use.");
|
2021-01-24 18:52:52 +00:00
|
|
|
},
|
2021-02-22 02:24:09 +00:00
|
|
|
updatefound() {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.log("New content is downloading.");
|
2021-01-24 18:52:52 +00:00
|
|
|
},
|
2021-02-22 02:24:09 +00:00
|
|
|
updated() {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.log("New content is available; please refresh.");
|
2021-01-24 18:52:52 +00:00
|
|
|
},
|
2020-09-10 16:39:01 +00:00
|
|
|
offline() {
|
|
|
|
console.log(
|
2021-02-22 02:39:04 +00:00
|
|
|
"No internet connection found. App is running in offline mode."
|
2020-09-10 16:39:01 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
error(error) {
|
2021-02-22 02:39:04 +00:00
|
|
|
console.error("Error during service worker registration:", error);
|
2020-09-10 16:39:01 +00:00
|
|
|
},
|
|
|
|
});
|