submitSelfie

abstract suspend fun submitSelfie(media: ByteArray, timestampInSeconds: Long, lat: Double?, lng: Double?): AFResult

Submits a Fit@Home selfie for the current member.

Return

true if the selfie was submitted successfully; false otherwise.

Parameters

media

The selfie image as a byte array.

timestampInSeconds

The epoch timestamp (seconds) when the selfie was taken.

lat

Optional latitude of the user’s location at submission.

lng

Optional longitude of the user’s location at submission.

Throws

if submission fails.

Android (Kotlin)

lifecycleScope.launch {
try {
val ok = AFCore.fitAtHome().submitSelfie(
media = selfieBytes,
timestampInSeconds = System.currentTimeMillis() / 1000,
lat = location?.latitude,
lng = location?.longitude
)
if (ok) showMessage("Selfie submitted!") else showError("Submit failed")
} catch (t: Throwable) {
showError("Submit failed: ${t.message}")
}
}

iOS (Swift)

Task {
do {
let ok = try await AFCore.shared.fitAtHome().submitSelfie(
media: selfieBytes,
timestampInSeconds: Int64(Date().timeIntervalSince1970),
lat: currentLocation?.latitude,
lng: currentLocation?.longitude
)
ok ? showMessage("Selfie submitted!") : showError("Submit failed")
} catch {
showError("Submit failed: \\(error.localizedDescription)")
}
}