subscribeToEvents

abstract fun subscribeToEvents(onEvent: (SmartWalkingEvent) -> Unit, onError: (Throwable) -> Unit = {}): FlowSubscription

Subscribes to SmartWalking lifecycle events (sync progress, permission changes, background delivery triggers).

Call FlowSubscription.close to stop receiving events.

Kotlin

val sub = AFCore.smartWalking().subscribeToEvents(
onEvent = { event ->
when (event) {
is SmartWalkingEvent.SyncCompleted -> println("Sync done: ${event.result.status}")
is SmartWalkingEvent.SyncFailed -> println("Sync failed: ${event.message}")
else -> {}
}
},
onError = { error -> println("Error: ${error.message}") }
)
// Later: sub.close()

Swift

let sub = AFCore.shared.smartWalking().subscribeToEvents(
onEvent: { event in
if let completed = event as? SmartWalkingEvent.SyncCompleted {
print("Sync done: \(completed.result.status)")
}
},
onError: { error in print("Error: \(error)") }
)
// Later: sub.close()

Return

A FlowSubscription — call FlowSubscription.close to stop.

Parameters

onEvent

Callback invoked for each SmartWalkingEvent.

onError

Callback invoked if the event collection fails.