From 3780eb9860e8a977a2694b043bba9ee2d6b83aee Mon Sep 17 00:00:00 2001 From: Mamalizz Date: Tue, 18 Mar 2025 20:36:09 +0330 Subject: [PATCH] added use pwa composable --- frontend/composables/global/usePwa.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 frontend/composables/global/usePwa.ts diff --git a/frontend/composables/global/usePwa.ts b/frontend/composables/global/usePwa.ts new file mode 100644 index 0000000..7b8fd55 --- /dev/null +++ b/frontend/composables/global/usePwa.ts @@ -0,0 +1,19 @@ +export const usePWA = () => { + const isInstalledAsPWA = ref(false); + + const checkPWAInstallation = () => { + const isStandalone = window.matchMedia( + "(display-mode: standalone)" + ).matches; + const isIOSPWA = (window.navigator as any).standalone; + isInstalledAsPWA.value = isStandalone || isIOSPWA; + }; + + onMounted(() => { + checkPWAInstallation(); + }); + + return { + isInstalledAsPWA, + }; +};