Files
TREK/client/src/native/platform.ts
T
Maurice 3beb5c4223 feat(native): the Android app's widgets, location, tile store, Play Billing and Google Wallet
The UI now turns these on by feature on Android as well as iOS:

- widgets, widgetTrips and the travel day (liveActivity) write the same
  snapshot to the Android app's Glance widgets; the travel day also sends
  the next stop's minutes and the stops' colours for the Live Update.
- geolocation answers navigator.geolocation from the app's location stream.
- tileCache: Android keeps Mapbox's resources in its WebView client, so the
  map is offline-capable there too, without the iOS trek-tile:// rewrite.
- playBilling: the purchase client buys through Google Play on Android,
  with the purchase token as the receipt the control plane verifies.
- googleWallet: a booking's button adds it to Google Wallet on Android,
  through the save link the server asks the TREK services for.
2026-11-07 14:11:59 +01:00

20 lines
617 B
TypeScript

import { Capacitor } from '@capacitor/core';
/** True inside the iOS and Android apps, where the WebView shows this server's UI. */
export function isNativeApp(): boolean {
return Capacitor.isNativePlatform();
}
export function isNativeIos(): boolean {
return isNativeApp() && Capacitor.getPlatform() === 'ios';
}
export function isNativeAndroid(): boolean {
return isNativeApp() && Capacitor.getPlatform() === 'android';
}
/** The server the app is connected to: the WebView sits on its origin. */
export function nativeServerHost(): string | null {
return isNativeApp() ? window.location.host : null;
}