From aba2ddd907d5fa16c7e57c71681a029d18c061ad Mon Sep 17 00:00:00 2001 From: Eric van der Vlist Date: Sat, 4 Mar 2023 20:52:11 +0100 Subject: [PATCH] Handling deep links to web.dyomedea.add, thus supporting invitations in the app too --- src/components/map/Map.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/components/map/Map.tsx b/src/components/map/Map.tsx index 7b9c748..feae88d 100644 --- a/src/components/map/Map.tsx +++ b/src/components/map/Map.tsx @@ -94,10 +94,19 @@ const Map: Component = () => { console.log({ caller: 'Intent receiver', intent }); if (intent.action === 'android.intent.action.VIEW') { const url = new URL(intent.data); - const q = url.search; - const [, lat, lon] = q.match(/q=([0-9.-]+),([0-9.-]+)/); - console.log({ caller: 'Intent receiver', intent, url, lat, lon }); - findLocation(navigate, [lon, lat]); + console.log({ caller: 'Intent receiver', intent, url }); + if (url.protocol === 'geo:') { + const q = url.search; + const [, lat, lon] = q.match(/q=([0-9.-]+),([0-9.-]+)/); + console.log({ caller: 'Intent receiver', intent, url, lat, lon }); + findLocation(navigate, [lon, lat]); + } else if ( + url.protocol === 'https:' && + url.hostname === 'web.dyomedea.app' + ) { + location.hash = url.hash; + location.pathname = url.pathname; + } } else if (intent.action === 'android.intent.action.SEND') { const uri = intent.extras['android.intent.extra.STREAM']; importUrls([uri]);