From b3ea202b2edd568dbc1d870d4ed0f41f429c389a Mon Sep 17 00:00:00 2001 From: smolgrrr Date: Tue, 23 Jul 2024 13:11:21 +1000 Subject: [PATCH] improve PWA check --- .../components/Modals/CheckMobile/CheckMobile.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/client/src/components/Modals/CheckMobile/CheckMobile.tsx b/client/src/components/Modals/CheckMobile/CheckMobile.tsx index 1244d12..32a8ff8 100644 --- a/client/src/components/Modals/CheckMobile/CheckMobile.tsx +++ b/client/src/components/Modals/CheckMobile/CheckMobile.tsx @@ -15,10 +15,14 @@ const AddToHomeScreenPrompt: React.FC = () => { useEffect(() => { const checkPWA = () => { - return ( - !window.navigator.standalone || - !window.matchMedia('(display-mode: standalone)').matches - ); + // Check if the app is running as a PWA on Android + const isAndroidPWA = window.matchMedia('(display-mode: standalone)').matches || + window.matchMedia('(display-mode: minimal-ui)').matches; + + // Check if the app is running as a PWA on other platforms + const isOtherPWA = window.navigator.standalone; + + return !isAndroidPWA && !isOtherPWA; }; // Function to detect mobile browser