subscribeToStatus

abstract fun subscribeToStatus(onStatus: (AFGeofencingStatus) -> Unit, onError: (Throwable) -> Unit = {}): FlowSubscription

Subscribes to live geofencing-status changes. Replays the latest value to the new collector and emits whenever the SDK transitions states (e.g., from PAUSED to ACTIVE once the user grants Always location, or to PERMISSIONS_DENIED if the permission is revoked in Settings).

Use this to drive reactive UI without polling isMonitoringActive. Call FlowSubscription.close to stop.

This is a state holder, not an event stream. It is backed by a Kotlin StateFlow, so it emits to existing collectors only when the status changes (consecutive equal values are conflated). It will not re-fire for a repeat startMonitoring call that leaves the status unchanged — for the outcome of a specific call, use the AFGeofencingResult returned by startMonitoring instead. A newly attached collector always receives the current value immediately on subscribe.

Parameters

onStatus

Callback invoked for each new (distinct) AFGeofencingStatus.

onError

Callback invoked if the status collection fails.