IosLocationTracker

iOS location via CoreLocation, counterpart to Android's FusedLocationProvider.

Configured for continuous background tracking:

  • requestWhenInUseAuthorization() first, then escalate to requestAlwaysAuthorization() once WhenInUse is granted (see locationDelegate's didChangeAuthorization callback). Requesting Always eagerly risks the OS silently downgrading the prompt to WhenInUse-only on some iOS versions if the user hasn't first seen (and accepted) the WhenInUse prompt.

  • allowsBackgroundLocationUpdates = true: required for continuous background tracking (the location background mode must also be listed in the app's Info.plist).

  • pausesLocationUpdatesAutomatically = false: prevents CoreLocation from silently halting delivery when the device is stationary, which would produce false zero-distance periods.

  • startMonitoringSignificantLocationChanges(): lets the OS relaunch a terminated/killed app when the device moves ~500 m.

The consuming app's Info.plist needs: UIBackgroundModes: location NSLocationAlwaysAndWhenInUseUsageDescription / NSLocationWhenInUseUsageDescription: an app-specific rationale string for the location prompt.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override val updates: Flow<GeoPoint>

Hot stream of location updates while tracking is active.

Functions

Link copied to clipboard
open suspend override fun current(): GeoPoint?

One-shot best-effort current location, or null if unavailable.

Link copied to clipboard
open override fun start()
Link copied to clipboard
open override fun stop()