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
credentialschange. - Performing pull-to-refresh or manual sync via
refresh(). - Handling unlock flows in Combine pipelines or SwiftUI
.taskmodifiers. - 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
-
Sets up the SDK using the provided client session token.
Throws
Throws:
SeamError.invalidClientSessionToken— if the provided token is malformed or invalid.SeamError.deactivationInProgress— if a deactivation operation is already running.SeamError.alreadyInitialized— if the SDK is already initialized without prior deactivation.
Example:
try Seam.initialize(clientSessionToken: "your_token")
Precondition
Precondition:
- Must be called before any other SDK methods.
- Initializing without a client session token will attempt to use the previous session if it is still valid.
- 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) throwsParameters
clientSessionTokenOptional - A valid client session token string.
-
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
credentialsis 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), callrefresh().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()AsynchronousStarts the SDK to begin credential synchronization and processing.
Precondition
Precondition:
initialize(clientSessionToken:)must be called before activating the SDK.
Throws
Throws:
SeamError.initializationRequired— ifinitialize(clientSessionToken:)hasn’t been called.SeamError.deactivationInProgress— if a deactivation operation is in progress.
await Seam.shared.activate()Declaration
Swift
public func activate() async throws -
refresh()AsynchronousRequests the latest credential list and updates the published
credentialsproperty.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:
SeamError.initializationRequired— if the SDK has not been initialized.SeamError.deactivationInProgress— if a deactivation operation is in progress.
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:
SeamError.initializationRequiredifinitialize(clientSessionToken:)has not been called.SeamError.invalidCredentialIdif no credential matches the provided identifier.SeamError.integrationNotFoundif the lock provider integration for the credential has not been configured.SeamError.credentialErrors([SeamCredentialError])if the specified credential has one or more associated errors.
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
credentialIdThe identifier of the credential to use for unlocking.
timeoutThe maximum time, in seconds, to wait for the unlock operation. Defaults to 10.
Return Value
A publisher emitting
SeamUnlockEventvalues as the unlock operation progresses. -
deactivate(deintegrate:Asynchronous) 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) asyncParameters
deintegrateIf
true, performs a full deintegration; iffalse, logs out and retains device endpoints. Defaults tofalse.
Install in Dash