Initializing the Seam Mobile SDK

1. Install the Seam SDK

The Seam SDK is available for download on request and is fully documented. See the Seam Android and iOS SDK reference documentation.

You must also use the Seam API to perform server-side actions. Consequently, install a Seam server-side SDK in the language of your choice if you have not done so already.

To install the Seam Android SDK:

  1. Copy the Seam Android SDK .aar file (for example, seam-phone-sdk-android.aar) into the libs directory for your project.

  2. Add the Android Archive (AAR) name (for example, seam-phone-sdk-android) to the dependencies block of the app/build.gradle file for your app.

    There may be additional dependencies required for your specific access control system. For details, see the appropriate system integration guide.

build.gradle.kts
plugins {
    id("com.android.application")
}

android { ... }

dependencies {
    // ...

    // Add the Seam Android SDK.
    implementation(project(":seam-phone-sdk-android"))
}

2. Implement any Manufacturer- and Mobile OS-Specific Requirements

Note the following manufacturer- and OS-specific requirements:

Manufacturer-Specific Requirements

See the device or system integration guide for the access control system or device for which you are planning to develop. Further, you may need to register for developer access with the ACS that you have chosen to use.


iOS Requirement

While not required, you can optionally request the com.apple.developer.passkit.pass-presentation-suppression entitlement from the Apple Developer portal. This entitlement prevents Apple Wallet from appearing when scanning for Bluetooth low energy (BLE) or similar locks, improving the unlock experience.


3. Configure a User Identity for your App User and Generate a Client Session Token

A user identity enables the application to request a user's mobile access permissions and use the app to unlock doors.

First, use the Seam API or Seam Console to create a user identity that will correspond to the App User Account using your internal user ID or other identifying information.

Then, using the user identity, create a client session and capture the resulting client session token. This token will be used to authenticate the user on your application.

# Create the user identity.
user_identity = seam.user_identities.create(
    email_address="[email protected]"
)

# Create the client session.
client_session = seam.client_sessions.create(
    user_identity_ids=[user_identity.user_identity_id]
)

# Use this token to launch your mobile controller.
token = client_session.token

4. Initialize the Mobile SDK with the Client Session Token

Use the client session token that you generated earlier to bootstrap the Seam SDK on the device. Under the hood, this action sets up credential synchronization and starts a background sync loop to keep permissions up to date.

Initialization and Error Handling

Perform initialization and activation within your app’s asynchronous context (for example, Swift’s Task or Kotlin coroutines) so that you can handle errors. The initialization call may fail due to configuration issues (such as an invalid token), and the activation call may fail due to network or runtime errors. Catch these errors and present a user-friendly message or fallback UI as appropriate.

import co.seam.sdk.Seam
import co.seam.sdk.SeamError


// Initialize the Seam client with the client session token. nclude the
// Android activity context and a .
val seam = SeamClient(
    clientSessionToken = seamClientSessionToken,
    androidContext = activityContext,
    seamEventHandler = 
)

try {
    seam.phone.native.initialize(
        // Opt into features with these options
        enableUnlockWithTap = true
    )
} catch (e: SeamError) {
    // Handle unrecoverable initialization errors.
}

Credential Errors

Any errors that occur between activation and deactivation surface on individual credential objects through their errors property. Observe the credentials array to detect and handle these errors:

import SeamSDK
import Combine

private var credentialErrorsCancellable: AnyCancellable?

func startMonitoringCredentialErrors() {
    credentialErrorsCancellable = Seam.shared.$credentials
        .sink { credentials in
            for credential in credentials where !credential.errors.isEmpty {
                print("Errors for \(credential.displayName):", credential.errors)
            }
        }
}

Credential Error Types

  • awaitingLocalCredential: The system is waiting for a local credential to become available.

  • expired: The credential has expired and is no longer valid.

  • userInteractionRequired(action): User interaction is required to resolve the credential issue; check the action for specifics.

  • contactSeamSupport: Configuration error requiring developer attention.

  • unsupportedDevice: The current device is not supported.

  • unknown: An unclassified or unexpected credential error occurred.

Possible userInteractionRequired Actions

  • completeOtpAuthorization(otpUrl:): The user must complete OTP authorization via the provided URL.

  • enableInternet: The user must enable internet connectivity.

  • enableBluetooth: The user must enable Bluetooth on the device.

  • grantBluetoothPermission: The user must grant Bluetooth permission to the app.

  • appRestartRequired: The user must restart the app to resolve the issue.

Last updated

Was this helpful?