iOS SDK

Prerequisites

Before integrating the SDK, ensure your development environment meets the following requirements:

  • Xcode version: 16.4
  • iOS Minimum Version: 16.6
  • Swift Tools version: 6.0

Adding the SDK to your project

You can add the iOS SDK to your project using Swift Package Manager.

1

In Xcode, navigate to File > Add Packages…

3

Select the desired version (the latest version is v0.9.0)

Required app integration steps

1

Our Mobile SDK requires camera, microphone, photo library and NFC reader permissions for capturing photos, videos and scanning legal documents during identification. Your application is responsible for declaring the reason why these permissions are used. You need to add the descriptions listed below to Info.plist of your application with the explanation of usage:

  • NSCameraUsageDescription
  • NSMicrophoneUsageDescription
  • NSPhotoLibraryUsageDescription
  • NFCReaderUsageDescription
2

You will also need to add the list of application IDs or AIDs it can connect to in your application’s Info.plist file. AIDs uniquely identify an application on an ISO 7816 tag.

1<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
2<array>
3 <string>D23300000045737445494420763335</string>
4 <string>A0000002471001</string>
5 <string>A0000002472001</string>
6 <string>00000000000000</string>
7</array>
3

You will need to introduce a new entitlement for NFC scanning. Xcode automatically adds this entitlement when you activate the Near Field Communication Tag Reading feature under Signing & Capabilities. Once this feature is enabled, the entitlements file should include the TAG format, as shown below.

1<key>com.apple.developer.nfc.readersession.formats</key>
2<array>
3 <string>TAG</string>
4</array>
4

You may be required to record and share a video with Apple demonstrating the usage of NFC scanning within your application.

Initialization

To initialize the SDK, create a subclass of the App class, and add the following code to your init() method:

1struct SampleAppApp: App {
2 init() {
3 IDmeSDK.shared.initialize(sdkConfig: sdkConfig)
4 }
5}

You will need to pass in an instance of IDmeSDKConfig while initializing the SDK. This example demonstrates how to create this config:

1private var sdkConfig: IDmeSDKConfig {
2 return IDmeSDKConfig(
3 externalUserId: "sample-user-id", // Unique identifier for the user
4 appName: "SampleApp", // Name of the app
5 tokenProvider: Self.tokenProvider
6 )
7}

The tokenProvider in the example is responsible for generating the client access token. This token enables the SDK to make REST API requests to ID.me’s backend APIs. The application must obtain a client access token from ID.me and provide a function to generate a new token if the current one expires. The SDK will then automatically use this to make REST API requests. This example illustrates the signature of this token provider method:

1static func tokenProvider() async throws -> String {
2 // Fetch client token from the backend and return it
3}

Common usage patterns

This section provides examples of common tasks you can perform with our Mobile SDK.

This section details the process of legal document and face liveness verification utilizing our Mobile SDK. Initiating a verification is straightforward, as demonstrated by the code snippets below.

1let manager = IDmeSDK.shared.getVerificationsManager()
2
3// Kick off document verification flow
4let workflowView = manager.createVerificationWorkflowView(
5 verificationType: .document
6) { result in
7 print("Verification result: \(result.verificationStatus)")
8}
9// Present workflowView in your SwiftUI hierarchy
10
11// Kick off face liveness verification flow
12let workflowView = manager.createVerificationWorkflowView(
13 verificationType: .faceLiveness
14) { result in
15 print("Verification result: \(result.verificationStatus)")
16}
17// Present workflowView in your SwiftUI hierarchy
1let manager = IDmeSDK.shared.getVerificationsManager()
2
3// Document verification flow
4manager.launchVerificationWorkflow(
5 from: self,
6 verificationType: .document
7) { result in
8 switch result.verificationStatus {
9 case .completed:
10 print("Success! Credential: \(result.credentialUuid ?? "")")
11 case .failed:
12 print("Failed: \(result.errorMessage ?? "")")
13 case .cancelled:
14 print("User cancelled")
15 default:
16 break
17}
18
19// Face liveness verification flow
20manager.launchVerificationWorkflow(
21 from: self,
22 verificationType: .faceLiveness
23) { result in
24 switch result.verificationStatus {
25 case .completed:
26 print("Success!")
27 case .failed:
28 print("Failed: \(result.errorMessage ?? "")")
29 case .cancelled:
30 print("User cancelled")
31 default:
32 break
33}

Checking the status of an ongoing verification

This section describes how to obtain the status of an ongoing verification.

// Returns the verificationID of the current verification and its status
IDmeSDK.shared.getVerificationsManager().getCurrentVerification()

Customizing the user interface

This section details how to customize the user interface. While default values are based on ID.me’s design system, you have the flexibility to replace any or all of these to align with your application’s aesthetic. We provide customization options for the following elements:

  • Colors: Modify the color scheme of various interface elements.
  • Button Radius: Control the roundness of buttons within the Mobile SDK.
  • Logo: Replace the default ID.me logo with your application’s logo.
  • Fonts: Choose the fonts used for all text displayed in the document scanner interface.
1let customBaseUIConfig = IDmeBaseUIConfig(
2 colors: IDmeBaseColors(
3 background: UIColor.<insert color>,
4 onBackground: UIColor.<insert color>,
5 onBackgroundSecondary: UIColor.<insert color>,
6 onBackgroundTertiary: UIColor.<insert color>,
7 primary: UIColor.<insert color>,
8 onPrimary: UIColor.<insert color>,
9 secondary: UIColor.<insert color>,
10 onSecondary: UIColor.<insert color>,
11 outline: UIColor.<insert color>,
12 success: UIColor.<insert color>,
13 error: UIColor.<insert color>
14 ),
15 buttonRadius: <insert button radius>,
16 logo: <insert logo>,
17 fonts: IDmeFonts(
18 regular: <insert font>,
19 medium: <insert font>,
20 bold: <insert font>,
21 semibold: <insert font>
22 ),
23 fontSizes: IDmeFontSizes(
24 textXs: <insert font size>,
25 textSm: <insert font size>,
26 textMd: <insert font size>,
27 display2Xs: <insert font size>
28 )
29)
30
31// Sets the custom UI config
32IdmeSDK.shared.getVerificationsManager().setBaseUIConfig(customBaseUIConfig)
33
34IdmeSDK.shared.getVerificationsManager().setDocScanUIConfig(customDocScanUIConfig)
35
36IdmeSDK.shared.getVerificationsManager().setFaceLivenessUIConfig(customFaceLivenessUIConfig)

Support

If you encounter any issues or have questions, please contact our developer support team. You can reach us at mobile-sdk-issues@id.me.