subscribeToLocationSharing

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

Subscribes to locationSharing with callbacks - the Swift-friendly form. Replays the latest attempt, then each new one; nothing is delivered before the first attempt.

Use it to keep a sharing status row current from Swift - it replaces the iOS AFCore.shared.subscribeToHeartbeat. Callbacks run on a background thread.

Android (Kotlin)

val subscription = AFCore.locations().subscribeToLocationSharing(
onStatus = { status -> runOnUiThread { renderSharing(status.outcome, status.trigger) } }
)
// Later: subscription.close()

iOS (Swift)

sharingSubscription = AFCore.shared.locations().subscribeToLocationSharing(
onStatus: { status in
Task { @MainActor in renderSharing(status.outcome, status.trigger) }
},
onError: { _ in }
)
// Later: sharingSubscription?.close()

Return

A FlowSubscription; call close() to stop.

Parameters

onStatus

Called for each recorded AFHeartbeatStatus.

onError

Called if collection fails.