geofence Events
A SharedFlow that emits AFGeofenceEvent instances as geofence transitions occur for the member's monitored facilities.
Events include AFGeofenceEvent.Entered, AFGeofenceEvent.Exited, AFGeofenceEvent.Dwell, AFGeofenceEvent.Registered, AFGeofenceEvent.Unregistered, AFGeofenceEvent.Heartbeat, and AFGeofenceEvent.Error.
Requires startMonitoring to be called first. Collect this flow from a coroutine scope, or use subscribeToEvents for a callback-based alternative.
Android (Kotlin)
lifecycleScope.launch {
AFCore.facilities().geofenceEvents.collect { event ->
when (event) {
is AFGeofenceEvent.Entered -> showNotification("Arrived at ${event.geofenceId}")
is AFGeofenceEvent.Exited -> showNotification("Left ${event.geofenceId}")
else -> { }
}
}
}Content copied to clipboard
iOS (Swift)
Use subscribeToEvents instead — Kotlin SharedFlow does not bridge directly to Swift AsyncSequence.