Skip to main content
Interim hand-authored reference. This page is authored from the SeamSDK public Swift sources. See the reference overview for context.

Overview

SeamUnlockEvent is a public enum representing the stages of a door unlock operation. The Seam.unlock(using:proximity:timeout:) method returns an AnyPublisher<SeamUnlockEvent, Never> that emits these events as the operation progresses.
public enum SeamUnlockEvent
Use the sequence of events to update your UI in response to connection status, success, timeouts, and errors.

Cases

CaseDescription
launchedThe unlock operation has started scanning for a lock.
grantedAccessThe lock granted access; entry is allowed.
timedOutThe unlock operation timed out before completing.
connectionFailed(debugDescription: String?)The unlock operation failed to connect. The associated debugDescription is an optional debug message with failure details.

connectionFailed(debugDescription:)

case connectionFailed(debugDescription: String?)
Emitted when the SDK cannot establish a connection to the lock hardware within the operation. The associated debugDescription provides optional diagnostic details for debugging — do not display it directly to end users.

Example

Async/Await

do {
    let credentialId = "some_credential_id"
    let stream = try Seam.shared.unlock(using: credentialId).values
    for await event in stream {
        switch event {
        case .launched:
            showSpinner()
        case .grantedAccess:
            hideSpinner()
            showSuccessBanner()
        case .timedOut:
            hideSpinner()
            showTimeoutError()
        case .connectionFailed(let debug):
            hideSpinner()
            showConnectionError(debug: debug)
        }
    }
} catch {
    // Handle errors thrown synchronously by unlock(using:)
}

Combine

var cancellable: AnyCancellable?

do {
    cancellable = try Seam.shared.unlock(using: credential.id)
        .sink { event in
            switch event {
            case .launched:       showSpinner()
            case .grantedAccess:  showSuccessBanner()
            case .timedOut:       showTimeoutError()
            case .connectionFailed: showConnectionError()
            }
        }
} catch {
    handleUnlockError(error)
}
See also: Seam.unlock(using:proximity:timeout:), SeamUnlockProximity