Handling deep links to web.dyomedea.add, thus supporting invitations in the app too

This commit is contained in:
Eric van der Vlist 2023-03-04 20:52:11 +01:00
parent c9be4dcc28
commit aba2ddd907
1 changed files with 13 additions and 4 deletions

View File

@ -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]);