From 0bbb358b7b9493b20ae5c7dcd559fdc0cd295dc7 Mon Sep 17 00:00:00 2001 From: AI Bot Date: Thu, 27 Aug 2026 15:13:31 -0500 Subject: [PATCH] fix(mobile-dock): ocultar boton app movil dentro de la aplicacion movil nativa y mostrar solo en navegacion web --- almeira-store-app/capacitor.config.ts | 2 + .../components/mobile/MobileBottomDock.tsx | 43 ++++++++++++++++--- dripzone-app/capacitor.config.ts | 2 + .../components/mobile/MobileBottomDock.tsx | 43 ++++++++++++++++--- sneaky-app/capacitor.config.ts | 2 + .../components/mobile/MobileBottomDock.tsx | 43 ++++++++++++++++--- zapply-app/capacitor.config.ts | 2 + .../components/mobile/MobileBottomDock.tsx | 43 ++++++++++++++++--- 8 files changed, 156 insertions(+), 24 deletions(-) diff --git a/almeira-store-app/capacitor.config.ts b/almeira-store-app/capacitor.config.ts index ac2938d..bc1d8b4 100644 --- a/almeira-store-app/capacitor.config.ts +++ b/almeira-store-app/capacitor.config.ts @@ -8,7 +8,9 @@ const config: CapacitorConfig = { url: 'https://store.almeira.com.co', cleartext: true, androidScheme: 'https', + appendUserAgent: 'CapacitorApp/AlmeiraStore', }, + appendUserAgent: 'CapacitorApp/AlmeiraStore', plugins: { SplashScreen: { launchShowDuration: 2000, diff --git a/almeira-store-app/src/components/mobile/MobileBottomDock.tsx b/almeira-store-app/src/components/mobile/MobileBottomDock.tsx index 6d11d64..06fe92e 100644 --- a/almeira-store-app/src/components/mobile/MobileBottomDock.tsx +++ b/almeira-store-app/src/components/mobile/MobileBottomDock.tsx @@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC = ({ const [isInsideApp, setIsInsideApp] = useState(false); useEffect(() => { - const isNativeApp = - typeof window !== 'undefined' && - (!!(window as any).Capacitor?.isNativePlatform?.() || + const detectApp = () => { + if (typeof window === 'undefined') return false; + + // 1. Capacitor bridge object o plataforma nativa + const isCapacitor = + typeof (window as any).Capacitor !== 'undefined' || + !!(window as any).Capacitor?.isNativePlatform?.() || (window as any).Capacitor?.getPlatform?.() === 'android' || - (window as any).Capacitor?.getPlatform?.() === 'ios' || + (window as any).Capacitor?.getPlatform?.() === 'ios'; + + // 2. Modo Standalone (PWA instalada o contenedor Android) + const isStandalone = window.matchMedia?.('(display-mode: standalone)')?.matches || - (window.navigator as any)?.standalone === true); - setIsInsideApp(isNativeApp); + (window.navigator as any)?.standalone === true || + document.referrer.includes('android-app://'); + + // 3. UserAgent personalizado o WebView embebida + const ua = (navigator.userAgent || '').toLowerCase(); + const isAppUA = + ua.includes('capacitor') || + ua.includes('capacitorapp') || + ua.includes('almeira') || + ua.includes('; wv') || + ua.includes('version/4.0'); + + return isCapacitor || isStandalone || isAppUA; + }; + + if (detectApp()) { + setIsInsideApp(true); + } + + const timer = setTimeout(() => { + if (detectApp()) { + setIsInsideApp(true); + } + }, 300); + + return () => clearTimeout(timer); }, []); const handleWhatsApp = () => { diff --git a/dripzone-app/capacitor.config.ts b/dripzone-app/capacitor.config.ts index 66ee8a2..f63c7e6 100644 --- a/dripzone-app/capacitor.config.ts +++ b/dripzone-app/capacitor.config.ts @@ -8,7 +8,9 @@ const config: CapacitorConfig = { url: 'https://dripzone.almeira.com.co', cleartext: true, androidScheme: 'https', + appendUserAgent: 'CapacitorApp/DripZone', }, + appendUserAgent: 'CapacitorApp/DripZone', plugins: { SplashScreen: { launchShowDuration: 4500, // 4.5 segundos para apreciar el logo y eslogan diff --git a/dripzone-app/src/components/mobile/MobileBottomDock.tsx b/dripzone-app/src/components/mobile/MobileBottomDock.tsx index b646e7e..df55b75 100644 --- a/dripzone-app/src/components/mobile/MobileBottomDock.tsx +++ b/dripzone-app/src/components/mobile/MobileBottomDock.tsx @@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC = ({ const [isInsideApp, setIsInsideApp] = useState(false); useEffect(() => { - const isNativeApp = - typeof window !== 'undefined' && - (!!(window as any).Capacitor?.isNativePlatform?.() || + const detectApp = () => { + if (typeof window === 'undefined') return false; + + // 1. Capacitor bridge object o plataforma nativa + const isCapacitor = + typeof (window as any).Capacitor !== 'undefined' || + !!(window as any).Capacitor?.isNativePlatform?.() || (window as any).Capacitor?.getPlatform?.() === 'android' || - (window as any).Capacitor?.getPlatform?.() === 'ios' || + (window as any).Capacitor?.getPlatform?.() === 'ios'; + + // 2. Modo Standalone (PWA instalada o contenedor Android) + const isStandalone = window.matchMedia?.('(display-mode: standalone)')?.matches || - (window.navigator as any)?.standalone === true); - setIsInsideApp(isNativeApp); + (window.navigator as any)?.standalone === true || + document.referrer.includes('android-app://'); + + // 3. UserAgent personalizado o WebView embebida + const ua = (navigator.userAgent || '').toLowerCase(); + const isAppUA = + ua.includes('capacitor') || + ua.includes('capacitorapp') || + ua.includes('dripzone') || + ua.includes('; wv') || + ua.includes('version/4.0'); + + return isCapacitor || isStandalone || isAppUA; + }; + + if (detectApp()) { + setIsInsideApp(true); + } + + const timer = setTimeout(() => { + if (detectApp()) { + setIsInsideApp(true); + } + }, 300); + + return () => clearTimeout(timer); }, []); const handleWhatsApp = () => { diff --git a/sneaky-app/capacitor.config.ts b/sneaky-app/capacitor.config.ts index dd2eed6..13699f0 100644 --- a/sneaky-app/capacitor.config.ts +++ b/sneaky-app/capacitor.config.ts @@ -8,7 +8,9 @@ const config: CapacitorConfig = { url: 'https://sneaky.almeira.com.co', cleartext: true, androidScheme: 'https', + appendUserAgent: 'CapacitorApp/SneakyDrops', }, + appendUserAgent: 'CapacitorApp/SneakyDrops', plugins: { SplashScreen: { launchShowDuration: 2000, diff --git a/sneaky-app/src/components/mobile/MobileBottomDock.tsx b/sneaky-app/src/components/mobile/MobileBottomDock.tsx index 81b3037..20f7032 100644 --- a/sneaky-app/src/components/mobile/MobileBottomDock.tsx +++ b/sneaky-app/src/components/mobile/MobileBottomDock.tsx @@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC = ({ const [isInsideApp, setIsInsideApp] = useState(false); useEffect(() => { - const isNativeApp = - typeof window !== 'undefined' && - (!!(window as any).Capacitor?.isNativePlatform?.() || + const detectApp = () => { + if (typeof window === 'undefined') return false; + + // 1. Capacitor bridge object o plataforma nativa + const isCapacitor = + typeof (window as any).Capacitor !== 'undefined' || + !!(window as any).Capacitor?.isNativePlatform?.() || (window as any).Capacitor?.getPlatform?.() === 'android' || - (window as any).Capacitor?.getPlatform?.() === 'ios' || + (window as any).Capacitor?.getPlatform?.() === 'ios'; + + // 2. Modo Standalone (PWA instalada o contenedor Android) + const isStandalone = window.matchMedia?.('(display-mode: standalone)')?.matches || - (window.navigator as any)?.standalone === true); - setIsInsideApp(isNativeApp); + (window.navigator as any)?.standalone === true || + document.referrer.includes('android-app://'); + + // 3. UserAgent personalizado o WebView embebida + const ua = (navigator.userAgent || '').toLowerCase(); + const isAppUA = + ua.includes('capacitor') || + ua.includes('capacitorapp') || + ua.includes('sneaky') || + ua.includes('; wv') || + ua.includes('version/4.0'); + + return isCapacitor || isStandalone || isAppUA; + }; + + if (detectApp()) { + setIsInsideApp(true); + } + + const timer = setTimeout(() => { + if (detectApp()) { + setIsInsideApp(true); + } + }, 300); + + return () => clearTimeout(timer); }, []); const handleWhatsApp = () => { diff --git a/zapply-app/capacitor.config.ts b/zapply-app/capacitor.config.ts index b619b9c..1697c94 100644 --- a/zapply-app/capacitor.config.ts +++ b/zapply-app/capacitor.config.ts @@ -8,7 +8,9 @@ const config: CapacitorConfig = { url: 'https://zapply.almeira.com.co', cleartext: true, androidScheme: 'https', + appendUserAgent: 'CapacitorApp/Zapply', }, + appendUserAgent: 'CapacitorApp/Zapply', plugins: { SplashScreen: { launchShowDuration: 2000, diff --git a/zapply-app/src/components/mobile/MobileBottomDock.tsx b/zapply-app/src/components/mobile/MobileBottomDock.tsx index 57b8bb3..b177bd6 100644 --- a/zapply-app/src/components/mobile/MobileBottomDock.tsx +++ b/zapply-app/src/components/mobile/MobileBottomDock.tsx @@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC = ({ const [isInsideApp, setIsInsideApp] = useState(false); useEffect(() => { - const isNativeApp = - typeof window !== 'undefined' && - (!!(window as any).Capacitor?.isNativePlatform?.() || + const detectApp = () => { + if (typeof window === 'undefined') return false; + + // 1. Capacitor bridge object o plataforma nativa + const isCapacitor = + typeof (window as any).Capacitor !== 'undefined' || + !!(window as any).Capacitor?.isNativePlatform?.() || (window as any).Capacitor?.getPlatform?.() === 'android' || - (window as any).Capacitor?.getPlatform?.() === 'ios' || + (window as any).Capacitor?.getPlatform?.() === 'ios'; + + // 2. Modo Standalone (PWA instalada o contenedor Android) + const isStandalone = window.matchMedia?.('(display-mode: standalone)')?.matches || - (window.navigator as any)?.standalone === true); - setIsInsideApp(isNativeApp); + (window.navigator as any)?.standalone === true || + document.referrer.includes('android-app://'); + + // 3. UserAgent personalizado o WebView embebida + const ua = (navigator.userAgent || '').toLowerCase(); + const isAppUA = + ua.includes('capacitor') || + ua.includes('capacitorapp') || + ua.includes('zapply') || + ua.includes('; wv') || + ua.includes('version/4.0'); + + return isCapacitor || isStandalone || isAppUA; + }; + + if (detectApp()) { + setIsInsideApp(true); + } + + const timer = setTimeout(() => { + if (detectApp()) { + setIsInsideApp(true); + } + }, 300); + + return () => clearTimeout(timer); }, []); const handleWhatsApp = () => {