submit Selfie
Submits a Fit@Home selfie for the current member.
Tries the network first and returns the server's answer. When no HTTP response is received (offline, timeout), the selfie is accepted into the offline outbox instead — the result carries status == true and queued == true — and is uploaded automatically on the next flush with its original capture time. Any HTTP response, including errors, surfaces verbatim and is never retried.
Return
An AFResult: status == true when the server accepted the selfie, or with queued == true when it was deferred to the outbox.
Parameters
The selfie image as JPEG (recommended) or PNG bytes. Empty bytes or any other format, such as HEIC, fail at once with status == false and the server's message, and are never queued.
The epoch timestamp (seconds) when the selfie was taken.
Optional latitude of the user’s location at submission.
Optional longitude of the user’s location at submission.
Throws
if submission fails.
Android (Kotlin)
lifecycleScope.launch {
val result = AFCore.fitAtHome().submitSelfie(
media = jpegBytes,
timestampInSeconds = System.currentTimeMillis() / 1000,
lat = location?.latitude,
lng = location?.longitude
)
when {
result.queued -> showMessage("Saved - it uploads when you're back online")
result.status -> showMessage("Selfie submitted!")
else -> showError(result.statusMessage ?: "Submit failed")
}
}iOS (Swift)
Task {
do {
// jpegBytes: a KotlinByteArray filled from the photo's JPEG Data
let result = try await AFCore.shared.fitAtHome().submitSelfie(
media: jpegBytes,
timestampInSeconds: Int64(Date().timeIntervalSince1970),
lat: location.map { KotlinDouble(value: $0.latitude) },
lng: location.map { KotlinDouble(value: $0.longitude) }
)
if result.queued {
showMessage("Saved - it uploads when you're back online")
} else if result.status {
showMessage("Selfie submitted!")
} else {
showError(result.statusMessage ?? "Submit failed")
}
} catch {
showError(error.localizedDescription)
}
}