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). When monitoring is started via com.advantahealth.api.facilities.Facilities.startMonitoring, the dwell time is configured automatically from application settings.
Notes
Geofences are typically created from facility data (facility coordinates + radius).
The dwell threshold is controlled by the application settings, which the SDK syncs automatically during initialization. Use com.advantahealth.api.settings.ApplicationSettings.getActiveFitSettings to inspect the current values.
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])