diff --git a/src/lib/amber.ts b/src/lib/amber.ts index bdf1f0d..ce0311a 100644 --- a/src/lib/amber.ts +++ b/src/lib/amber.ts @@ -291,26 +291,22 @@ function buildCallbackUrl(): string { /** * Navigate to an Amber nostrsigner: URL. * - * In Capacitor WebView, custom URI schemes must be opened via a - * temporary element click — this triggers Android's intent system - * correctly without the WebView trying to load it as an asset URL - * (window.location.href) or stripping query params (window.open _system). + * Amber has two code paths depending on how it receives the intent: + * + * 1. NATIVE path (no Browser.EXTRA_APPLICATION_ID): reads type from + * intent EXTRAS — not set when coming from a WebView URL navigation. + * + * 2. WEB/BROWSER path (Browser.EXTRA_APPLICATION_ID present): reads type + * from URL query params — set when a browser/WebView opens a URL. + * + * We need the WEB path. window.open('url', '_blank') causes the WebView + * to open the URL as a browser navigation, which sets + * Browser.EXTRA_APPLICATION_ID and routes Amber to parse our URL params. */ function openAmberUrl(url: string): void { - const isCapacitor = !!(window as unknown as { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor?.isNativePlatform?.(); - if (isCapacitor) { - // Create a temporary anchor and click it — this is the only reliable - // way to fire an Android intent from a Capacitor WebView without - // the WebView intercepting the navigation or stripping query params. - const a = document.createElement('a'); - a.href = url; - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - setTimeout(() => document.body.removeChild(a), 100); - } else { - window.location.href = url; - } + // _blank triggers the browser intent path in Android WebView, + // which sets Browser.EXTRA_APPLICATION_ID so Amber reads URL query params. + window.open(url, '_blank'); } /**