send Location Event
Sends a location-based event to the Advanta backend.
The event is posted to the geofence endpoint and is typically used to mirror geofence transitions (enter / exit / dwell) for a known location. The SDK's own geofence engine produces these same events automatically; this function exists for hosts that drive location tracking themselves and need to report transitions manually.
Return
Nothing. The call completes normally when the event has been accepted (or successfully enqueued); failures are signalled by a thrown Throwable.
Parameters
The geofence transition type as an integer. The SDK uses 1 = enter, 2 = exit, 3 = dwell (see the geofence transition types emitted by the internal geofence engine). Pass the value that matches the transition you are reporting.
The UTC timestamp, in milliseconds since the Unix epoch, at which the event occurred. This value is forwarded verbatim to the backend, so it should reflect the actual capture time (e.g. System.currentTimeMillis() on Android, Date().timeIntervalSince1970 * 1000 on iOS). The current system time zone is attached automatically.
The unique identifier of the location where the event occurred (e.g. a geofence / facility ID). May be null if not known.
The latitude of the event location. May be null if unavailable.
The longitude of the event location. May be null if unavailable.
The duration, in whole minutes, associated with the event — such as the time spent inside a geofence for a dwell event. Pass null (or 0) for enter/exit events, where it is ignored.
Throws
if the request fails.
Android (Kotlin)
lifecycleScope.launch {
try {
AFCore.events().sendLocationEvent(
eventType = 1,
locationId = 12345L,
latitude = 34.0522,
longitude = -118.2437,
timeStamp = System.currentTimeMillis(),
dwellMinutes = null
)
showMessage("Location event sent successfully")
} catch (t: Throwable) {
showError("Failed to send location event: ${t.message}")
}
}iOS (Swift)
Task {
do {
try await AFCore.shared.events().sendLocationEvent(
eventType: 1,
locationId: 12345,
latitude: 34.0522,
longitude: -118.2437,
timeStamp: Int64(Date().timeIntervalSince1970 * 1000),
dwellMinutes: nil
)
self.showMessage("Location event sent successfully")
} catch {
self.showError("Failed to send location event: \(error.localizedDescription)")
}
}