improve PWA check

This commit is contained in:
smolgrrr 2024-07-23 13:11:21 +10:00
parent aaaeb75aac
commit b3ea202b2e

View File

@ -15,10 +15,14 @@ const AddToHomeScreenPrompt: React.FC = () => {
useEffect(() => { useEffect(() => {
const checkPWA = () => { const checkPWA = () => {
return ( // Check if the app is running as a PWA on Android
!window.navigator.standalone || const isAndroidPWA = window.matchMedia('(display-mode: standalone)').matches ||
!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 // Function to detect mobile browser