You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This guide demonstrates how to request necessary system permissions, such as Bluetooth or Location Access. The SDK enables your application to identify and request the necessary permissions for specific features. Additionally, it details how to display warnings or banners within your application when required permissions are not enabled.
3
+
The mobile SDK surfaces missing or required system permissions (Bluetooth, internet connectivity, and so on) as `CredentialError.userInteractionRequired(action)` entries in each credential’s `errors` array. After activation, observe these errors and handle the specified actions. Errors update automatically as requirements change.
4
4
5
-
## Retrieving and Requesting Required Permissions at Start Up
6
-
7
-
Upon launch, the application needs to request the necessary permissions from the user. To retrieve the obtain the list of required permissions, use the `listRequiredAndroidPermissions` or `listRequiredIosPermissions` methods, and specify the features the application will be using.
5
+
## Monitoring Permission Errors
8
6
9
7
{% tabs %}
8
+
10
9
{% tab title="Android Kotlin" %}
11
10
```kotlin
12
-
val requiredPermissions = seam.phone.native.listRequiredAndroidPermissions(
Once you've acquired the list of required permissions, please refer to relevant Android and iOS documentation for guidance on adding system permissions. 
36
-
37
-
<figure><imgsrc="../../../.gitbook/assets/image (6).png"alt=""><figcaption><p>Requesting Required System Permissions for your App</p></figcaption></figure>
38
57
39
-
***
58
+
The mobile SDK automatically clears resolved permission errors once the required permission is granted, reflecting the updated credential state.
40
59
41
-
## Perform a System Check and Display Warnings
60
+
## Handling Permission Actions
42
61
43
-
An app user may choose to deny the application's permission requests. Before launching any features, your application must perform a system check. If the required permissions are not enabled, the app must inform the user, and instruct the user to enable them.
62
+
Implement your handler for each action:
44
63
45
64
{% tabs %}
65
+
46
66
{% tab title="Android Kotlin" %}
47
67
```kotlin
48
-
funhandleEvent(
49
-
event:SeamEvent
50
-
) {
51
-
// Check whether the phone state has changed.
52
-
// Note that these events are located under the phone namespace.
53
-
if (event isSeamEvent.Phone) {
54
-
val phone = seam.phone.get().nativeMetadata
55
-
56
-
if (
57
-
// The desired state has not been met.
58
-
!phone.canUnlockWithTap
59
-
) {
60
-
if (phone.errors.any { it isSeamError.Phone.Native.MissingRequiredAndroidPermissions }) {
61
-
// Need to update the required permissions.
62
-
val requiredPermissions = seam.phone.native.listRequiredAndroidPermissions(
63
-
enableUnlockWithTap =true
64
-
)
65
-
66
-
// Request the requiredPermissions or prompt the user to do so.
// Prompt the user to enable network connectivity.
85
+
case .enableBluetooth:
86
+
// Prompt the user to turn on Bluetooth.
87
+
case .grantBluetoothPermission:
88
+
// Prompt the user to grant Bluetooth permission in Settings.
96
89
}
97
90
}
98
91
```
99
92
{% endtab %}
100
93
{% endtabs %}
101
94
102
-
<figure><img src="../../../.gitbook/assets/image (7).png" alt=""><figcaption><p>Inform the user to enable required system permissions.</p></figcaption></figure>
103
95
96
+
## See also
97
+
98
+
For a complete SwiftUI-based implementation of credential error handling for iOS, see `SeamUnlockCardView` in the SeamComponents library, which demonstrates observing credential errors and updating the UI accordingly.
Copy file name to clipboardExpand all lines: docs/capability-guides/mobile-access/mobile-device-sdks/initializing-the-seam-mobile-sdk.md
+77-95Lines changed: 77 additions & 95 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,21 +36,39 @@ dependencies {
36
36
{% endtab %}
37
37
38
38
{% tab title="iOS Swift" %}
39
-
To install the Seam iOS SDK, add the `SeamSdk.podspec` to the `target` block of your [Podfile](https://guides.cocoapods.org/using/using-cocoapods.html).
39
+
You can install SeamSDK via CocoaPods or Swift Package Manager (SPM).
40
+
SeamSDK supports per-lock-provider integration granularity. Include only the modules you need to keep your app footprint minimal.
40
41
41
42
{% code title="Podfile" %}
42
43
```ruby
43
44
use_frameworks!
44
-
45
-
platform :ios, '...'
45
+
platform :ios, '15.0'
46
46
47
47
target 'YourApp'do
48
-
// ...
49
-
//Local pod install with file path to SeamSdk.podspec
50
-
pod 'SeamSdk', :path => './SeamSdk.podspec'
48
+
# Local pod install with file path to SeamSdk.podspec
49
+
pod 'SeamSDK', :path => 'PATH_TO_SEAM_SDK/SeamSDK.podspec'
50
+
# Optional subspecs for specific providers:
51
+
pod 'SeamSDK/SeamDormakabaIntegration', :path => 'PATH_TO_SEAM_SDK/SeamSDK.podspec'
52
+
pod 'SeamSDK/SeamLatchIntegration', :path => 'PATH_TO_SEAM_SDK/SeamSDK.podspec'
51
53
end
52
54
```
53
55
{% endcode %}
56
+
57
+
{% tabs %}
58
+
{% tab title="SPM" %}
59
+
```swift
60
+
dependencies: [
61
+
.package(path: "PATH_TO_SEAM_SDK/SeamSDK")
62
+
],
63
+
targets: [
64
+
.target(
65
+
name: "YourApp",
66
+
dependencies: ["SeamSDK", "SeamSaltoIntegration"]
67
+
)
68
+
]
69
+
```
70
+
{% endtab %}
71
+
{% endtabs %}
54
72
{% endtab %}
55
73
{% endtabs %}
56
74
@@ -68,19 +86,15 @@ See the [device or system integration guide](../../../device-and-system-integrat
68
86
69
87
### iOS Requirement
70
88
71
-
If you are developing an iOS app, add [`requestAutomaticPassPresentationSuppression()`](https://developer.apple.com/documentation/passkit/pkpasslibrary/requestautomaticpasspresentationsuppression\(responsehandler:\)) to your app to prevent the user's phone from displaying Apple Wallet while scanning for Bluetooth low energy (BLE) or similar locks. This method suppresses Apple Wallet while your mobile app is in the foreground.
72
-
73
-
{% hint style="info" %}
74
-
The use of this method requires a special entitlement from Apple.
75
-
{% endhint %}
89
+
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.
76
90
77
91
***
78
92
79
93
## 3. Configure a User Identity for your App User and Generate a Client Session Token
80
94
81
95
A [user identity](../managing-mobile-app-user-accounts-with-user-identities.md) enables the application to request a user's mobile access permissions and use the app to unlock doors.
82
96
83
-
First, use the Seam API to create a [user identity](../managing-mobile-app-user-accounts-with-user-identities.md#what-is-a-user-identity) that will correspond to the App User Account using your internal user ID or other identifying information.
97
+
First, use the Seam API or Seam Console to create a [user identity](../managing-mobile-app-user-accounts-with-user-identities.md#what-is-a-user-identity) that will correspond to the App User Account using your internal user ID or other identifying information.
84
98
85
99
Then, using the user identity, create a [client session](../../../core-concepts/authentication/client-session-tokens/) and capture the resulting [client session token](../../../core-concepts/authentication/client-session-tokens/). This token will be used to authenticate the user on your application.
## 4. Initialize the Mobile SDK with the Client Session Token
191
207
192
-
Use the client session token generated earlier to initialize the Seam Mobile SDK. This initializes the Mobile SDK for the app user, and retrieves the relevant provider-specific settings. This also launches a background process that will continually poll for any updates to the access permissions.
193
208
194
-
### Initialization and Handling Configuration Errors
209
+
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.
210
+
211
+
### Initialization and Error Handling
195
212
196
-
The initialization process may fail if the Seam workspace or provider-specific settings are not configured properly. If the initialization process encounters any irrecoverable errors, this block will catch these exceptions, specifically those identified as `SeamError`. These errors point to development errors, and should be addressed by making sure that your Workspace and User Identity is configured properly.
213
+
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.
197
214
198
215
{% tabs %}
199
216
{% tab title="Android Kotlin" %}
@@ -223,94 +240,59 @@ try {
223
240
224
241
{% tab title="iOS Swift" %}
225
242
```swift
226
-
importSeam
227
-
228
-
// client session token for th user
229
-
let clientSessionToken =
230
-
231
-
let seam =SeamClient(
232
-
clientSessionToken: clientSessionToken,
233
-
seamEventDelegate:
234
-
)
235
-
236
-
try seam.phone.native.initialize(
237
-
enableUnlockWithTap: true
238
-
)
243
+
importSeamSDK
244
+
245
+
// Initialize the Mobile SDK with the client session token (CST).
246
+
Task {
247
+
do {
248
+
// Bootstrap the SDK with the CST from your login flow.
### Handling Provider Initialization Errors from the Background Process
244
-
245
-
Any failures during the background process will produce errors. These errors can be accessed from the error list, and events will also be emitted. To handle these operational errors, you may log the error in logs or displaying a message to the user.
246
262
247
-
{% tabs %}
248
-
{% tab title="Android Kotlin" %}
249
-
```kotlin
250
-
fun (
251
-
seam:Seam,
252
-
event:SeamEvent
253
-
) {
254
-
// If the event is under the phone namespace, the phone state may have changed.
255
-
if event isSeamEvent.Phone {
256
-
val phone = seam.phone.get().nativeMetadata
257
-
258
-
// Check for the desired state of the phone for all app features to work.
259
-
if (!phone.isInitialized ||!phone.canUnlockWithTap) {
// SeamError.Internal.Phone.Native.ProviderInitializationFailure: Android version not compatible.
268
-
269
-
// Display error message and disable functionality/access,
270
-
// until the user resolves the issue.
271
-
} else {
272
-
// Set the UI state to indicate that all app features are working.
273
-
}
274
-
}
275
-
}
263
+
### Credential Errors
276
264
277
-
val seam =SeamClient(
278
-
seamEventHandler = eventHandler,
279
-
// ...
280
-
)
281
-
```
282
-
{% endtab %}
265
+
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:
283
266
284
-
{% tab title="iOS Swift" %}
285
267
```swift
286
-
func (
287
-
seam: Seam,
288
-
event: SeamEvent
289
-
) {
290
-
// If the event is under the phone namespace, the phone state may have changed.
291
-
switch(event) {
292
-
case .phone:
293
-
let phone = seam.phone.get().nativeMetadata// Coming soon!
294
-
295
-
// Check for the desired state of the phone for all app features to work.
296
-
if (!phone.isInitialized||!phone.canUnlockWithTap) {
0 commit comments