logout

abstract suspend fun logout(): AFResult

Signs the user out and clears local session state.

Before ending the session it removes this install's push registration (the deviceId of the last successful messaging().updateToken()), best effort and for at most 3 seconds, only while the access token is still valid; it never refreshes the token for it and never fails the logout. Call messaging().deleteToken() before this when the removal must happen.

Return

An AFResult whose status is true when the logout flow completed; the local session is cleared either way.

Throws

if an unexpected error occurs during the process.

Android (Kotlin) — settings > sign out

lifecycleScope.launch {
try {
val result = AFCore.authentication().logout()
if (result.status) navigateToSignIn()
} catch (t: Throwable) {
showError("Logout failed: ${t.message}")
}
}

iOS (Swift) — settings > sign out

Task {
do {
let result = try await AFCore.shared.authentication().logout()
if result.status { navigateToSignIn() }
} catch {
showError("Logout failed: \\(error.localizedDescription)")
}
}