Skip to main content
Interim hand-authored reference. This page is authored directly from the Seam Android SDK public Kotlin sources. See the reference overview for context.

Overview

SeamUnlockEvent is a sealed class representing the stages of a door unlock operation. As SeamSDK.getInstance().unlock() progresses, the SDK emits these events to the unlockStatus StateFlow.
sealed class SeamUnlockEvent {
    class ScanningStarted : SeamUnlockEvent()
    class AccessGranted : SeamUnlockEvent()
    class Timeout : SeamUnlockEvent()
    class ReaderError(val message: String) : SeamUnlockEvent()
}
Subscribe to unlockStatus before calling unlock() to ensure no events are missed.

Subtypes

SubtypeDescription
ScanningStartedThe unlock operation has started scanning for a reader.
AccessGrantedThe reader granted access; entry is allowed.
TimeoutThe unlock operation timed out before completing.
ReaderError(val message: String)An error occurred while communicating with the reader. The message property contains diagnostic details.

ReaderError

class ReaderError(val message: String) : SeamUnlockEvent()
Emitted when the SDK encounters an error communicating with the reader hardware. The message property contains diagnostic details intended for developers — do not display it directly to end users.

Example

val seamSDK = SeamSDK.getInstance()

// Subscribe before calling unlock
lifecycleScope.launch {
    seamSDK.unlockStatus.collect { event ->
        when (event) {
            is SeamUnlockEvent.ScanningStarted -> {
                showScanningSpinner()
            }
            is SeamUnlockEvent.AccessGranted -> {
                hideScanningSpinner()
                showSuccessBanner()
            }
            is SeamUnlockEvent.Timeout -> {
                hideScanningSpinner()
                showTimeoutError()
            }
            is SeamUnlockEvent.ReaderError -> {
                hideScanningSpinner()
                // event.message contains diagnostic details
                showReaderError()
            }
        }
    }
}

// Then perform the unlock
try {
    seamSDK.unlock(
        credentialId = credential.id!!,
        unlockProximity = UnlockProximity.TOUCH
    )
} catch (seamError: SeamError) {
    // Handle synchronous errors thrown before scanning begins
    handleUnlockError(seamError)
}
See also: SeamSDK.unlock(), UnlockProximity