subscribe To Location Sharing
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()Content copied to clipboard
iOS (Swift)
sharingSubscription = AFCore.shared.locations().subscribeToLocationSharing(
onStatus: { status in
Task { @MainActor in renderSharing(status.outcome, status.trigger) }
},
onError: { _ in }
)
// Later: sharingSubscription?.close()Content copied to clipboard
Return
A FlowSubscription; call close() to stop.
Parameters
on Status
Called for each recorded AFHeartbeatStatus.
on Error
Called if collection fails.