From 126cd840f5a7db767110a9b93a620b1a0e9365f3 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Tue, 8 Sep 2026 01:50:22 +0200 Subject: [PATCH] =?UTF-8?q?fix(landing):=20masque=20=C2=AB=20Ouvrir=20dans?= =?UTF-8?q?=20l'application=20=C2=BB=20dans=20l'app=20native=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `isMobile = isAndroidPhoneBrowser()` est une détection d'user-agent : la WebView Capacitor contient « Android »/« Mobile », donc le bouton « Ouvrir dans l'application » s'affichait aussi *dans* l'app packagée — où le taper tente de relancer l'app via le scheme, échoue, et retombe sur `/telecharger`. - Nouveau `canOfferApp = isMobile && !Capacitor.isNativePlatform()` — « un navigateur *téléphone* où pousser l'app native a du sens ». Gate le bouton et la rétrogradation de « Créer un compte » en secondaire. - Le lien `/telecharger` (variante desktop) gagne aussi `&& !Capacitor.isNativePlatform()` : sur tablette la WebView Capacitor peut ne pas avoir « Mobile » dans son UA, donc `!isMobile` ne suffisait pas. Aucun changement sur le web (`Capacitor.isNativePlatform()` y est toujours `false`, donc `canOfferApp === isMobile`) — `landing.feature` (navigateur téléphone + desktop) revérifiée, 7/7. Le chemin natif n'a pas de couture de test depuis un run web (limitation déjà documentée, cf. `app-settings-page.cy.ts`). Closes #103 Co-Authored-By: Claude Sonnet 5 --- apps/web/src/pages/landing/LandingPage.tsx | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/apps/web/src/pages/landing/LandingPage.tsx b/apps/web/src/pages/landing/LandingPage.tsx index 38b0f5c..366a15f 100644 --- a/apps/web/src/pages/landing/LandingPage.tsx +++ b/apps/web/src/pages/landing/LandingPage.tsx @@ -1,3 +1,4 @@ +import { Capacitor } from "@capacitor/core"; import { CalendarDays, HeartPulse, Smartphone, Sparkles, Users } from "lucide-react"; import type { ReactNode } from "react"; import { useTranslation } from "react-i18next"; @@ -29,6 +30,13 @@ export function LandingPage() { // whether the viewport is narrow (a resized desktop window shouldn't // attempt a scheme navigation just because it's a small window). const isMobile = isAndroidPhoneBrowser(); + // ...but the Capacitor WebView's UA *also* contains "Android"/"Mobile", + // so `isMobile` alone is true inside the packaged app too — where + // "Ouvrir dans l'application" is nonsense (you're already in it; tapping + // it just tries to re-launch via the scheme, fails, and lands on + // `/telecharger`). `canOfferApp` is the real "a phone *browser* where + // pushing the native app is worthwhile" flag (issue #103). + const canOfferApp = isMobile && !Capacitor.isNativePlatform(); function handleOpenApp() { attemptOpenNativeApp({ onFallback: () => navigate("/telecharger") }); @@ -69,7 +77,7 @@ export function LandingPage() { * this button doesn't render at all (see the plain `/telecharger` * link below instead, replacing the old direct-APK link). */} - {isMobile && ( + {canOfferApp && (