credentials
Returns the list of SeamCredential for the current app user.
This StateFlow emits an immutable list whenever credentials change. The list may be empty if no credentials are available or while loading. Check each credential's errors
property to determine if it's ready for use.
The flow is thread-safe and can be collected from any coroutine context. Latest value is always available via .value
property.
// Observe credentials
seamSDK.credentials.collect { credentials ->
// credentials is a list of [SeamCredential]
if (credentials.isEmpty()) {
// handle no credentials
} else {
// handle credentials (e.g. display them)
}
}
// handle credential errors
SeamSDK.getInstance().credentials.collect { credentialsList ->
val errors = credentialsList.flatMap { it.errors }
errors.forEach { error ->
when (error) {
is SeamCredentialError.Expired -> { /* handle credential expiration error */}
is SeamCredentialError.Loading -> { /* handle not loaded yet */}
is SeamCredentialError.Unknown -> { /* handle unknown error */}
is SeamCredentialError.UserInteractionRequired -> {
handleUserInteractionRequired(error.interaction)
}
}
}
}
fun handleUserInteractionRequired(interaction: SeamRequiredUserInteraction) {
when (interaction) {
is SeamRequiredUserInteraction.CompleteOtpAuthorization -> { /* handle OTP authorization */}
is SeamRequiredUserInteraction.EnableBluetooth -> { /* handle Bluetooth error */}
is SeamRequiredUserInteraction.EnableInternet -> { /* handle Internet connection error*/}
is SeamRequiredUserInteraction.GrantPermissions -> { /* handle permissions error*/}
}
}
Content copied to clipboard