sendLocationEvent

abstract suspend fun sendLocationEvent(eventType: Int, timeStamp: Long, locationId: Long?, latitude: Double?, longitude: Double?, dwellMinutes: Int?)

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 once the backend has accepted the event; failures are signalled by a thrown Throwable.

Parameters

eventType

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.

timeStamp

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.

locationId

The unique identifier of the location where the event occurred (e.g. a geofence / facility ID). May be null if not known.

latitude

The latitude of the event location. May be null if unavailable.

longitude

The longitude of the event location. May be null if unavailable.

dwellMinutes

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. This call posts directly and is not queued for later delivery, so an event sent with no usable network path is lost — retry it yourself if it matters. (The SDK's own geofence engine does queue the transitions it produces; that is a separate path from this manual one.)

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,
timeStamp: Int64(Date().timeIntervalSince1970 * 1000),
locationId: KotlinLong(longLong: 12345),
latitude: KotlinDouble(value: 34.0522),
longitude: KotlinDouble(value: -118.2437),
dwellMinutes: nil
)
self.showMessage("Location event sent successfully")
} catch {
self.showError("Failed to send location event: \(error.localizedDescription)")
}
}