subscribe To Location Sharing Enabled
abstract fun subscribeToLocationSharingEnabled(onState: (Boolean) -> Unit, onError: (Throwable) -> Unit = {}): FlowSubscription
Subscribes to locationSharingEnabled with callbacks - for binding a SwiftUI toggle to the opt-in. Replays the current value, then each change.
Use it from Swift to reflect the opt-in - it replaces the iOS AFCore.shared.subscribeToHeartbeatEnabled. Callbacks run on a background thread; in Swift the value arrives as a KotlinBoolean (read .boolValue).
Android (Kotlin)
val subscription = AFCore.locations().subscribeToLocationSharingEnabled(
onState = { enabled -> runOnUiThread { sharingSwitch.isChecked = enabled } }
)
// Later: subscription.close()Content copied to clipboard
iOS (Swift)
enabledSubscription = AFCore.shared.locations().subscribeToLocationSharingEnabled(
onState: { enabled in
Task { @MainActor in self.isSharing = enabled.boolValue }
},
onError: { _ in }
)
// Later: enabledSubscription?.close()Content copied to clipboard
Return
A FlowSubscription; call close() to stop.
Parameters
on State
Called with the current opt-in, then on each change.
on Error
Called if collection fails.