send Location Event
abstract suspend fun sendLocationEvent(eventType: Int, timeStamp: Long, timeZoneOffset: String, locationId: Long?, latitude: Double?, longitude: Double?, dwellMinutes: Int?)
Sends a location-based event to the Advanta backend.
Parameters
event Type
An integer representing the type of event (e.g., 1 for 'enter', 2 for 'dwell', 3 for 'exit').
location Id
The unique identifier of the location where the event occurred (e.g., a geofence ID).
latitude
The latitude of the event location.
longitude
The longitude of the event location.
time Stamp
The UTC timestamp (in milliseconds) when the event occurred.
time Zone Offset
The device's current timezone offset from UTC (e.g., "America/Tijuana").
dwell Minutes
The duration in minutes related to the event, such as the time spent inside a geofence. Ignored for Entry/Exit.
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(),
timeZoneOffset = "America/New_York",
dwellMinutes = null
)
showMessage("Location event sent successfully")
} catch (t: Throwable) {
showError("Failed to send location event: ${t.message}")
}
}Content copied to clipboard
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),
timeZoneOffset: "America/New_York",
dwellMinutes: nil
)
self.showMessage("Location event sent successfully")
} catch {
self.showError("Failed to send location event: \(error.localizedDescription)")
}
}Content copied to clipboard