AFGeofencing Result
Outcome of a geofencing control operation (e.g. starting monitoring).
Returned synchronously to report whether monitoring became active or failed outright.
Typical flows
Success — monitoring is active; no further action needed (equivalent to AFGeofencingStatus.ACTIVE).
Failure — the operation could not be completed (including blocked permission states such as While-Using-only or reduced accuracy); inspect
message/causeand branch on Failure.status to react immediately.
Failure.status carries the AFGeofencingStatus published at call time so consumers can react synchronously without wiring up com.advantahealth.api.facilities.Facilities.subscribeToStatus. Note it is best-effort: on iOS the Always-upgrade grant is asynchronous, so a call that triggers the "Always Allow" prompt returns the pre-upgrade status (e.g. PERMISSIONS_FOREGROUND_ONLY); the resolved PERMISSIONS_REDUCED_ACCURACY lands a beat later on subscribeToStatus(), which remains the source of truth.
when (val result = AFCore.geofencing().startMonitoring()) {
is AFGeofencingResult.Success -> showMonitoringActive()
is AFGeofencingResult.Failure -> when (result.status) {
AFGeofencingStatus.PERMISSIONS_REDUCED_ACCURACY -> promptForPreciseLocation()
AFGeofencingStatus.PERMISSIONS_DENIED -> openAppSettings()
else -> showError(result.message, result.cause)
}
}Inheritors
Types
Operation failed with an error.
Operation completed successfully — geofencing is actively monitoring.