subscribe To Visit Detection Status
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()Content copied to clipboard
iOS (Swift)
statusSubscription = AFCore.shared.locations().subscribeToVisitDetectionStatus(
onStatus: { status in
Task { @MainActor in renderToggle(status == .active) }
},
onError: { _ in }
)
// Later: statusSubscription?.close()Content copied to clipboard
Return
A FlowSubscription; call close() to stop.
Parameters
on Status
Called for each new AFGeofencingStatus.
on Error
Called if collection fails.