subscribe To Events
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()Content copied to clipboard
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()Content copied to clipboard
Return
A FlowSubscription — call FlowSubscription.close to stop.
Parameters
on Event
Callback invoked for each SmartWalkingEvent.
on Error
Callback invoked if the event collection fails.