subscribeToVisitDetectionStatus

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

Subscribes to the monitoring session status. Replays the current value, then emits each distinct change - for example PAUSED to ACTIVE once the member grants Always location.

Use it to drive an automatic check-in toggle reactively - it replaces facilities().subscribeToStatus(). It is a state holder: a repeated startVisitDetection that leaves the status unchanged emits nothing, so read that call's own result for its outcome. Callbacks run on a background thread.

Android (Kotlin)

val subscription = AFCore.locations().subscribeToVisitDetectionStatus(
onStatus = { status -> runOnUiThread { renderToggle(status == AFGeofencingStatus.ACTIVE) } }
)
// Later: subscription.close()

iOS (Swift)

statusSubscription = AFCore.shared.locations().subscribeToVisitDetectionStatus(
onStatus: { status in
Task { @MainActor in renderToggle(status == .active) }
},
onError: { _ in }
)
// Later: statusSubscription?.close()

Return

A FlowSubscription; call close() to stop.

Parameters

onStatus

Called for each new AFGeofencingStatus.

onError

Called if collection fails.