diff --git a/client/src/lib/platform.ts b/client/src/lib/platform.ts index e461f10..3c59979 100644 --- a/client/src/lib/platform.ts +++ b/client/src/lib/platform.ts @@ -36,19 +36,19 @@ export function detectPlatform(): PlatformType { return cachedPlatform; } - // Capacitor check - sometimes injected late, so don't cache 'web' result immediately - // IMPORTANT: Capacitor has a web implementation that creates window.Capacitor - // We need to check if we're in a REAL native app, not just the web polyfill + // Capacitor check - only detect mobile on actual native platforms if (window.Capacitor !== undefined) { - // Check if we're actually in a native app by checking for native platform - const isRealNative = (window.Capacitor as any)?.getPlatform && - (window.Capacitor as any).getPlatform() !== 'web'; - if (isRealNative) { - console.log('[Platform] Detected: mobile (Capacitor native)'); - cachedPlatform = 'mobile'; - return cachedPlatform; - } else { - console.log('[Platform] Capacitor detected but running on web - treating as web'); + try { + // Capacitor has getPlatform() that returns 'android', 'ios', or 'web' + const capacitorPlatform = (window.Capacitor as any).getPlatform?.(); + if (capacitorPlatform === 'android' || capacitorPlatform === 'ios') { + console.log('[Platform] Detected: mobile (Capacitor on ' + capacitorPlatform + ')'); + cachedPlatform = 'mobile'; + return cachedPlatform; + } + console.log('[Platform] Capacitor running on web platform - ignoring'); + } catch (e) { + console.log('[Platform] Capacitor check failed - treating as web'); } } diff --git a/client/src/main.tsx b/client/src/main.tsx index e93a14c..4e46299 100644 --- a/client/src/main.tsx +++ b/client/src/main.tsx @@ -7,13 +7,13 @@ const App = lazy(() => import("./App")); const LoadingScreen = () => (