submit

abstract suspend fun submit(facilityId: Int, timestampInSeconds: Long, timeSpentInMinutes: Int, latitude: Double? = null, longitude: Double? = null, atFacility: Boolean = false): AFResult

Submits a self-report for a facility visit.

Typically used when a member wants to manually record a visit to a facility that was not automatically tracked.

Return

AFResult indicating the result of the submission.

Parameters

facilityId

The ID of the visited facility.

timestampInSeconds

Epoch timestamp (seconds) when the visit occurred.

timeSpentInMinutes

Duration of the visit in seconds.

latitude

Optional latitude of the visit location.

longitude

Optional longitude of the visit location.

atFacility

Whether the user was physically at the facility (true) or remote (false).

Throws

if submission fails.

Android (Kotlin)

lifecycleScope.launch {
try {
val result = AFCore.selfReport().submit(
facilityId = 123,
timestampInSeconds = System.currentTimeMillis() / 1000,
timeSpentInMinutes = 30,
latitude = currentLat,
longitude = currentLng,
atFacility = true
)
if (result.success) showMessage("Self-report submitted")
else showError("Submission failed: ${result.message}")
} catch (t: Throwable) {
showError("Submission failed: ${t.message}")
}
}

iOS (Swift)

Task {
do {
let result = try await AFCore.shared.selfReport().submit(
facilityId: 123,
timestampInSeconds: Int64(Date().timeIntervalSince1970),
timeSpentInSeconds: 30,
latitude: currentLat,
longitude: currentLng,
atFacility: true
)
result.success ? self.showMessage("Self-report submitted")
: self.showError("Submission failed: \\(result.message ?? "")")
} catch {
self.showError("Submission failed: \\(error.localizedDescription)")
}
}