Seam

public final class Seam : ObservableObject

Manages the Seam SDK lifecycle: initialization, activation, credential sync, unlock operations, and cleanup.

Quick Start

try Seam.initialize(clientSessionToken: "token")
await Seam.shared.activate()

Use Cases

  • Bootstrapping the SDK at app launch (initialize + activate).
  • Reactively updating UI when credentials change.
  • Performing pull-to-refresh or manual sync via refresh().
  • Handling unlock flows in Combine pipelines or SwiftUI .task modifiers.
  • Cleaning up resources on logout or account switch with deactivate().
  • The shared singleton instance of Seam.

    Use this instance to interact with the Seam SDK once it has been initialized.

    Declaration

    Swift

    public static let shared: Seam

Initialization

  • Sets up the SDK using the provided client session token.

    Throws

    Throws:

    • Example:

      try Seam.initialize(clientSessionToken: "your_token")
      

    Precondition

    Precondition:

    • Must be called before any other SDK methods.
    • If you need to reinitialize, first call deactivate(deintegrate:) to clean up the previous SDK session.
    • Thread-safe: can be invoked from any thread.

    Declaration

    Swift

    public static func initialize(clientSessionToken: String) throws

    Parameters

    clientSessionToken

    A valid client session token string.

    Return Value

    Void

  • A published list of current credentials, automatically synchronized in the background. Subscribe to updates to refresh your UI or business logic.

    The current list of credentials managed by the Seam SDK.

    This property is published and always reflects the latest credentials as managed by the SDK. Subscribe to this property to observe changes and update your UI or business logic accordingly.

    Note

    credentials is automatically kept up-to-date as changes occur (e.g., remote or local updates). If you want to explicitly trigger a refresh (for example, after a user pull-to-refresh action), call refresh().

    Declaration

    Swift

    @Published
    public private(set) var credentials: [SeamCredential] { get set }
  • A published Boolean indicating whether the SDK is active. Use this to enable or disable UI or logic based on the SDK’s activation state.

    Indicates whether the Seam SDK is currently active.

    This property is published and reflects the current activation state of the SDK. Use this property to enable or disable UI or logic depending on whether Seam is active.

    Declaration

    Swift

    @Published
    public private(set) var isActive: Bool { get set }
  • activate() Asynchronous

    Starts the SDK to begin credential synchronization and processing.

    Precondition

    Precondition:

    Throws

    Throws:

    await Seam.shared.activate()
    

    Declaration

    Swift

    public func activate() async throws

    Return Value

    Void

  • refresh() Asynchronous

    Requests the latest credential list and updates the published credentials property.

    Note

    Credentials are automatically synchronized in the background—calling this method is optional and intended for manual refresh actions (e.g., pull-to-refresh UI).

    Throws

    Throws:

    Task {
        do {
            let updatedCredentials = try await Seam.shared.refresh()
            // Update UI or state with `updatedCredentials`
        } catch {
            // Optionally, handle refresh errors
        }
    }
    

    Declaration

    Swift

    public func refresh() async throws -> [SeamCredential]

    Return Value

    An array of refreshed SeamCredentials.

  • Unlocks a door or device using the given credential ID.

    Throws

    Throws:

    • Example:

      let publisher = try Seam.shared.unlock(using: credential.id)
      

    Declaration

    Swift

    public func unlock(using credentialId: String, timeout: TimeInterval = 10.0) throws -> AnyPublisher<SeamUnlockEvent, Never>

    Parameters

    credentialId

    The identifier of the credential to use for unlocking.

    timeout

    The maximum time, in seconds, to wait for the unlock operation. Defaults to 10.

    Return Value

    A publisher emitting SeamUnlockEvent values as the unlock operation progresses.

  • Stops the SDK and releases resources, optionally removing device association.

      await Seam.shared.deactivate()
    

    Precondition

    • initialize() must have been called.
    • Safe to call multiple times; idle calls are no-ops.

    Declaration

    Swift

    public func deactivate(deintegrate: Bool = false) async

    Parameters

    deintegrate

    If true, performs a full deintegration; if false, logs out and retains device endpoints. Defaults to false.

    Return Value

    Void