added installed as pwa checking
This commit is contained in:
@@ -7,9 +7,19 @@ export default defineNuxtPlugin(() => {
|
||||
if ("serviceWorker" in navigator) {
|
||||
wb = new Workbox("/sw.js");
|
||||
|
||||
const isStandalone = window.matchMedia(
|
||||
"(display-mode: standalone)"
|
||||
).matches;
|
||||
const isIOSPWA = (window.navigator as any).standalone;
|
||||
const isInstalledAsPWA = isStandalone || isIOSPWA;
|
||||
|
||||
// Listen for messages from the service worker
|
||||
navigator.serviceWorker.addEventListener("message", (event) => {
|
||||
if (event.data && event.data.type === "VERSION_CHECK") {
|
||||
if (
|
||||
event.data &&
|
||||
event.data.type === "VERSION_CHECK" &&
|
||||
isInstalledAsPWA
|
||||
) {
|
||||
checkForUpdate(event.data.version);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user