fix(mobile-dock): ocultar boton app movil dentro de la aplicacion movil nativa y mostrar solo en navegacion web
This commit is contained in:
parent
e675ec3641
commit
0bbb358b7b
@ -8,7 +8,9 @@ const config: CapacitorConfig = {
|
|||||||
url: 'https://store.almeira.com.co',
|
url: 'https://store.almeira.com.co',
|
||||||
cleartext: true,
|
cleartext: true,
|
||||||
androidScheme: 'https',
|
androidScheme: 'https',
|
||||||
|
appendUserAgent: 'CapacitorApp/AlmeiraStore',
|
||||||
},
|
},
|
||||||
|
appendUserAgent: 'CapacitorApp/AlmeiraStore',
|
||||||
plugins: {
|
plugins: {
|
||||||
SplashScreen: {
|
SplashScreen: {
|
||||||
launchShowDuration: 2000,
|
launchShowDuration: 2000,
|
||||||
|
|||||||
@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC<MobileBottomDockProps> = ({
|
|||||||
const [isInsideApp, setIsInsideApp] = useState(false);
|
const [isInsideApp, setIsInsideApp] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isNativeApp =
|
const detectApp = () => {
|
||||||
typeof window !== 'undefined' &&
|
if (typeof window === 'undefined') return false;
|
||||||
(!!(window as any).Capacitor?.isNativePlatform?.() ||
|
|
||||||
|
// 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?.() === '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.matchMedia?.('(display-mode: standalone)')?.matches ||
|
||||||
(window.navigator as any)?.standalone === true);
|
(window.navigator as any)?.standalone === true ||
|
||||||
setIsInsideApp(isNativeApp);
|
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 = () => {
|
const handleWhatsApp = () => {
|
||||||
|
|||||||
@ -8,7 +8,9 @@ const config: CapacitorConfig = {
|
|||||||
url: 'https://dripzone.almeira.com.co',
|
url: 'https://dripzone.almeira.com.co',
|
||||||
cleartext: true,
|
cleartext: true,
|
||||||
androidScheme: 'https',
|
androidScheme: 'https',
|
||||||
|
appendUserAgent: 'CapacitorApp/DripZone',
|
||||||
},
|
},
|
||||||
|
appendUserAgent: 'CapacitorApp/DripZone',
|
||||||
plugins: {
|
plugins: {
|
||||||
SplashScreen: {
|
SplashScreen: {
|
||||||
launchShowDuration: 4500, // 4.5 segundos para apreciar el logo y eslogan
|
launchShowDuration: 4500, // 4.5 segundos para apreciar el logo y eslogan
|
||||||
|
|||||||
@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC<MobileBottomDockProps> = ({
|
|||||||
const [isInsideApp, setIsInsideApp] = useState(false);
|
const [isInsideApp, setIsInsideApp] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isNativeApp =
|
const detectApp = () => {
|
||||||
typeof window !== 'undefined' &&
|
if (typeof window === 'undefined') return false;
|
||||||
(!!(window as any).Capacitor?.isNativePlatform?.() ||
|
|
||||||
|
// 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?.() === '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.matchMedia?.('(display-mode: standalone)')?.matches ||
|
||||||
(window.navigator as any)?.standalone === true);
|
(window.navigator as any)?.standalone === true ||
|
||||||
setIsInsideApp(isNativeApp);
|
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 = () => {
|
const handleWhatsApp = () => {
|
||||||
|
|||||||
@ -8,7 +8,9 @@ const config: CapacitorConfig = {
|
|||||||
url: 'https://sneaky.almeira.com.co',
|
url: 'https://sneaky.almeira.com.co',
|
||||||
cleartext: true,
|
cleartext: true,
|
||||||
androidScheme: 'https',
|
androidScheme: 'https',
|
||||||
|
appendUserAgent: 'CapacitorApp/SneakyDrops',
|
||||||
},
|
},
|
||||||
|
appendUserAgent: 'CapacitorApp/SneakyDrops',
|
||||||
plugins: {
|
plugins: {
|
||||||
SplashScreen: {
|
SplashScreen: {
|
||||||
launchShowDuration: 2000,
|
launchShowDuration: 2000,
|
||||||
|
|||||||
@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC<MobileBottomDockProps> = ({
|
|||||||
const [isInsideApp, setIsInsideApp] = useState(false);
|
const [isInsideApp, setIsInsideApp] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isNativeApp =
|
const detectApp = () => {
|
||||||
typeof window !== 'undefined' &&
|
if (typeof window === 'undefined') return false;
|
||||||
(!!(window as any).Capacitor?.isNativePlatform?.() ||
|
|
||||||
|
// 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?.() === '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.matchMedia?.('(display-mode: standalone)')?.matches ||
|
||||||
(window.navigator as any)?.standalone === true);
|
(window.navigator as any)?.standalone === true ||
|
||||||
setIsInsideApp(isNativeApp);
|
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 = () => {
|
const handleWhatsApp = () => {
|
||||||
|
|||||||
@ -8,7 +8,9 @@ const config: CapacitorConfig = {
|
|||||||
url: 'https://zapply.almeira.com.co',
|
url: 'https://zapply.almeira.com.co',
|
||||||
cleartext: true,
|
cleartext: true,
|
||||||
androidScheme: 'https',
|
androidScheme: 'https',
|
||||||
|
appendUserAgent: 'CapacitorApp/Zapply',
|
||||||
},
|
},
|
||||||
|
appendUserAgent: 'CapacitorApp/Zapply',
|
||||||
plugins: {
|
plugins: {
|
||||||
SplashScreen: {
|
SplashScreen: {
|
||||||
launchShowDuration: 2000,
|
launchShowDuration: 2000,
|
||||||
|
|||||||
@ -23,14 +23,45 @@ export const MobileBottomDock: React.FC<MobileBottomDockProps> = ({
|
|||||||
const [isInsideApp, setIsInsideApp] = useState(false);
|
const [isInsideApp, setIsInsideApp] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isNativeApp =
|
const detectApp = () => {
|
||||||
typeof window !== 'undefined' &&
|
if (typeof window === 'undefined') return false;
|
||||||
(!!(window as any).Capacitor?.isNativePlatform?.() ||
|
|
||||||
|
// 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?.() === '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.matchMedia?.('(display-mode: standalone)')?.matches ||
|
||||||
(window.navigator as any)?.standalone === true);
|
(window.navigator as any)?.standalone === true ||
|
||||||
setIsInsideApp(isNativeApp);
|
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 = () => {
|
const handleWhatsApp = () => {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user