Bytt djuplenkjer frå tilfluktsrom:// til HTTPS App Links
SMS-appar gjenkjenner ikkje eigendefinerte URI-skjema som klikkbare lenkjer. Brukar no https://tilfluktsrom.naiv.no/shelter/{id} som opnar appen direkte (Android App Links med autoVerify) eller fell tilbake til PWA i nettlesaren. Android: DEEP_LINK_DOMAIN i build.gradle.kts, HTTPS intent-filter, oppdatert handleDeepLinkIntent og shareShelter med HTTPS-URL. PWA: assetlinks.json for Android-verifisering, djuplenkjehandtering i app.ts, base-sti endra frå './' til '/', config.ts for domene. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ae249d5d47
commit
015bc0d926
14 changed files with 114 additions and 15 deletions
12
pwa/public/.well-known/assetlinks.json
Normal file
12
pwa/public/.well-known/assetlinks.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[
|
||||
{
|
||||
"relation": ["delegate_permission/common.handle_all_urls"],
|
||||
"target": {
|
||||
"namespace": "android_app",
|
||||
"package_name": "no.naiv.tilfluktsrom",
|
||||
"sha256_cert_fingerprints": [
|
||||
"43:05:79:6F:EA:3E:F4:50:45:D3:8A:EF:EA:58:B6:65:49:D2:D2:C3:4B:4C:61:11:EE:74:48:B0:C7:70:E4:5B"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
import type { Shelter, ShelterWithDistance, LatLon } from './types';
|
||||
import { t } from './i18n/i18n';
|
||||
import { formatDistance } from './util/distance-utils';
|
||||
import { formatDistance, distanceMeters, bearingDegrees } from './util/distance-utils';
|
||||
import { findNearest } from './location/shelter-finder';
|
||||
import * as repo from './data/shelter-repository';
|
||||
import * as locationProvider from './location/location-provider';
|
||||
|
|
@ -43,6 +43,7 @@ export async function init(): Promise<void> {
|
|||
setupShelterList();
|
||||
setupButtons();
|
||||
await loadData();
|
||||
handleDeepLink();
|
||||
}
|
||||
|
||||
/** Set localized aria-labels and wire the about button. */
|
||||
|
|
@ -398,3 +399,67 @@ async function forceRefresh(): Promise<void> {
|
|||
statusBar.setStatus(t('update_failed'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle /shelter/{lokalId} deep links.
|
||||
* Called after loadData() so allShelters is populated.
|
||||
*/
|
||||
function handleDeepLink(): void {
|
||||
const match = window.location.pathname.match(/^\/shelter\/(.+)$/);
|
||||
if (!match) return;
|
||||
|
||||
const lokalId = decodeURIComponent(match[1]);
|
||||
|
||||
// Clean the URL so refresh doesn't re-trigger
|
||||
window.history.replaceState({}, '', '/');
|
||||
|
||||
const shelter = allShelters.find((s) => s.lokalId === lokalId);
|
||||
if (!shelter) {
|
||||
statusBar.setStatus(t('error_shelter_not_found'));
|
||||
return;
|
||||
}
|
||||
|
||||
selectShelterByData(shelter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a specific shelter, even if it's not in the current nearest-3 list.
|
||||
* Used for deep link targets.
|
||||
*/
|
||||
function selectShelterByData(shelter: Shelter): void {
|
||||
// Check if it's already in nearestShelters
|
||||
const existingIdx = nearestShelters.findIndex(
|
||||
(s) => s.shelter.lokalId === shelter.lokalId,
|
||||
);
|
||||
|
||||
if (existingIdx >= 0) {
|
||||
userSelectedShelter = true;
|
||||
selectedShelterIndex = existingIdx;
|
||||
} else {
|
||||
// Compute distance/bearing if we have a location, otherwise use placeholder
|
||||
let dist = NaN;
|
||||
let bearing = 0;
|
||||
if (currentLocation) {
|
||||
dist = distanceMeters(
|
||||
currentLocation.latitude, currentLocation.longitude,
|
||||
shelter.latitude, shelter.longitude,
|
||||
);
|
||||
bearing = bearingDegrees(
|
||||
currentLocation.latitude, currentLocation.longitude,
|
||||
shelter.latitude, shelter.longitude,
|
||||
);
|
||||
}
|
||||
|
||||
// Prepend to the list so it becomes the selected shelter
|
||||
nearestShelters.unshift({
|
||||
shelter,
|
||||
distanceMeters: dist,
|
||||
bearingDegrees: bearing,
|
||||
});
|
||||
userSelectedShelter = true;
|
||||
selectedShelterIndex = 0;
|
||||
shelterList.updateList(nearestShelters, selectedShelterIndex);
|
||||
}
|
||||
|
||||
updateSelectedShelter(true);
|
||||
}
|
||||
|
|
|
|||
2
pwa/src/config.ts
Normal file
2
pwa/src/config.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
/** Deep link domain — single source of truth for the PWA. */
|
||||
export const DEEP_LINK_DOMAIN = 'tilfluktsrom.naiv.no';
|
||||
|
|
@ -46,6 +46,7 @@ export const en: Record<string, string> = {
|
|||
'No cached data available. Connect to the internet to download shelter data.',
|
||||
update_success: 'Shelter data updated',
|
||||
update_failed: 'Update failed \u2014 using cached data',
|
||||
error_shelter_not_found: 'Shelter not found',
|
||||
|
||||
// Accessibility
|
||||
direction_arrow_description: 'Direction to shelter, %s away',
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export const nb: Record<string, string> = {
|
|||
'Ingen lagrede data tilgjengelig. Koble til internett for å laste ned tilfluktsromdata.',
|
||||
update_success: 'Tilfluktsromdata oppdatert',
|
||||
update_failed: 'Oppdatering mislyktes — bruker lagrede data',
|
||||
error_shelter_not_found: 'Fant ikke tilfluktsrommet',
|
||||
|
||||
// Tilgjengelighet
|
||||
direction_arrow_description: 'Retning til tilfluktsrom, %s unna',
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ export const nn: Record<string, string> = {
|
|||
'Ingen lagra data tilgjengeleg. Kopla til internett for å laste ned tilfluktsromdata.',
|
||||
update_success: 'Tilfluktsromdata oppdatert',
|
||||
update_failed: 'Oppdatering mislukkast — brukar lagra data',
|
||||
error_shelter_not_found: 'Fann ikkje tilfluktsrommet',
|
||||
|
||||
// Tilgjenge
|
||||
direction_arrow_description: 'Retning til tilfluktsrom, %s unna',
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { defineConfig } from 'vite';
|
|||
import { VitePWA } from 'vite-plugin-pwa';
|
||||
|
||||
export default defineConfig({
|
||||
base: './',
|
||||
base: '/',
|
||||
define: {
|
||||
// Injected as a global — changes every build, breaking any stale cache
|
||||
__BUILD_REVISION__: JSON.stringify(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue