AFGeofence
AFGeofence — represents a circular geofence used for presence detection.
A geofence defines a geographic region where entry, exit, or dwell events can be triggered. AFCore uses these to detect member visits around com.advantahealth.api.facilities.model.Facility locations.
Properties
id Unique identifier for the geofence (string).
latitude, longitude Center point of the geofence.
radius Radius in meters (default = 150m).
dwellTimeMillis Minimum time in milliseconds that the user must remain inside the region for a dwell event to be triggered (default =
0L= not tracked).
Notes
Geofences are typically created from facility data (facility coordinates + radius).
dwellTimeMilliscan be set to avoid false positives when members briefly pass by.Use with com.advantahealth.api.activities.Activities.submitAutomaticVisit
Android (Kotlin) — creating a geofence
val gymGeofence = AFGeofence(
id = "facility_42",
latitude = 32.7157,
longitude = -117.1611,
radius = 200f,
dwellTimeMillis = 5 * 60 * 1000L // 5 minutes
)
AFCore.geofencing().startMonitoring(listOf(gymGeofence))iOS (Swift) — monitoring a geofence
let parkGeofence = AFGeofence(
id: "central_park",
latitude: 40.7851,
longitude: -73.9683,
radius: 300,
dwellTimeMillis: 0
)
try await AFCore.shared.geofencing().startMonitoring([parkGeofence])