Verwendung

Register background updates

tsx
import { location, permissions, storage } from 'kuito';

// At module scope: a background launch runs the app's modules, not its UI.
location.defineUpdates('run', async ({ locations }) => {
  const track: unknown[] = JSON.parse((await storage.get('track')) ?? '[]');

  await storage.set('track', JSON.stringify([...track, ...locations.map((fix) => fix.coords)]));
});

async function startRun() {
  const { status } = await permissions.request('locationAlways');

  if (status === 'granted')
    await location.startUpdates('run', {
      accuracy: 'high',
      distanceInterval: 10,
      notification: { title: 'Recording your run' },
    });
}

Signaturen

ts
(name: string, options?: LocationTaskOptions): Promise<void>

Parameter

NameTypErforderlichBeschreibung
namestringJa—
optionsLocationTaskOptionsNein—
Standard: {}

Rückgabe

Promise<void>

Generiert aus den öffentlichen TypeScript-Deklarationen: Signaturen, Props und Standardwerte stammen aus der geprüften Quelle, Beschreibungen aus deren JSDoc. Kein Standardwert ist erfunden.