start Monitoring
Starts monitoring presence events for the member’s facilities.
Geofences are registered for all verified facilities. The dwell threshold (how long the member must remain inside a facility region for a visit to be recorded) is determined by the application settings, which the SDK syncs automatically during initialization.
Call stopMonitoring when monitoring is no longer required to release resources.
Return
An AFGeofencingResult indicating the outcome:
AFGeofencingResult.Success — geofencing is actively monitoring.
AFGeofencingResult.Pending — geofences were registered but location permissions have not yet been granted. Observe geofenceEvents or poll the geofencing status to know when monitoring becomes active.
AFGeofencingResult.Failure — monitoring could not be started (e.g., no facilities, permissions denied, or platform unsupported).
Throws
if monitoring cannot be started.
Android (Kotlin)
lifecycleScope.launch {
when (val result = AFCore.facilities().startMonitoring()) {
is AFGeofencingResult.Success -> log("Monitoring active")
is AFGeofencingResult.Pending -> log("Waiting for permissions: ${result.message}")
is AFGeofencingResult.Failure -> showError("Failed: ${result.message}")
}
}iOS (Swift)
Task {
let result = try await AFCore.shared.facilities().startMonitoring()
switch result {
case is AFGeofencingResultSuccess:
print("Monitoring active")
case let pending as AFGeofencingResultPending:
print("Waiting for permissions: \(pending.message ?? "")")
case let failure as AFGeofencingResultFailure:
print("Failed: \(failure.message ?? "")")
}
}