authenticateWithCredentials

abstract suspend fun authenticateWithCredentials(username: String, password: String): AFResult

Attempts to authenticate the user with username and password.

Return

true if authentication succeeded; false if credentials were invalid.

Parameters

username

The user’s username (typically email).

password

The user’s password.

Throws

on network errors or unexpected responses.

Android (Kotlin) — sign-in screen

lifecycleScope.launch {
try {
val ok = AFCore.authentication().authenticateWithCredentials(username.text, password.text)
if (ok) navigateToHome() else showError("Invalid credentials")
} catch (t: Throwable) {
showError("Sign in failed: ${t.message}")
}
}

iOS (Swift) — sign-in screen

Task {
do {
let ok = try await AFCore.shared.authentication().authenticateWithCredentials(
username: usernameField.text ?? "",
password: passwordField.text ?? ""
)
if ok { navigateToHome() } else { showError("Invalid credentials") }
} catch {
showError("Sign in failed: \\(error.localizedDescription)")
}
}