Get started with iOS SDK

Latest release: Version 1.31.0 (Changelog)

Requirements

  • Xcode 14.1+
  • iOS 11.0 or later
    • MRTDReader module requires iOS 13+

🚧

Attention

Make sure bitcode is disabled for your project.

Resources

Installation

The framework is available to install with Swift Package Manager or CocoaPods.

Swift package manager

Add https://github.com/SumSubstance/IdensicMobileSDK-iOS.git to your project as a package dependency:

  • Add IdensicMobileSDK library to your target.
  • Add optional libraries if you need them. For more information, see MRTDReader and VideoIdent.

📘

Note

Twilio since 5.0.0 only supports iOS 12.2+. If you want to use Twilio higher than 4.6.3, set the ios-12.2 branch when adding the package dependency and ensure that your minimum deployment target is iOS 12.2+.

CocoaPods

  1. Update your Podfile:
    • Add source options for SumSubstance and CocoaPods repositories.
    • Add IdensicMobileSDK dependency to your target.
    • Add optional dependencies if you need them. For more information, see MRTDReader and VideoIdent.
platform :ios, '11.0'

source 'https://cdn.cocoapods.org/'
source 'https://github.com/SumSubstance/Specs.git'

target 'YourApp' do
  pod 'IdensicMobileSDK'
  # pod 'IdensicMobileSDK/MRTDReader'
  # pod 'IdensicMobileSDK/VideoIdent'

  # any other dependencies
end
  1. Run the following command in your project directory.
pod install

Permissions

The framework will ask for access to the camera and microphone, photo library, and geolocation. Because of this, it is required to have the corresponding usage descriptions in the application Info.plist file.

<key>NSCameraUsageDescription</key>
<string>Let us take a photo</string>
<key>NSMicrophoneUsageDescription</key>
<string>Time to record a video</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Let us pick a photo</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Please provide us with your geolocation data to prove your current location</string>

📘

Note

If your app targets iOS 10 and below, it is required to turn on the iCloud Documents capabilities in Xcode as described in this article.

Modules

MRTDReader (NFC)

The MRTDReader is an optional module that allows SDK to detect and read the electronic chips placed on MRTD documents via NFC.

To enable this functionality:

  1. Add the module:
    • Swift Package Manager — add the IdensicMobileSDK_MRTDReader library to your target.
    • CocoaPods — add the IdensicMobileSDK/MRTDReader dependency into your Podfile.
  2. Turn on the Near Field Communication Tag Reading capability for your project target.
  3. Update the application Info.plist file as follows:
<key>NFCReaderUsageDescription</key>
<string>Let us scan the document for more precise recognition</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
    <string>A0000002471001</string>
    <string>A0000002472001</string>
    <string>00000000000000</string>
</array>

VideoIdent

The VideoIdent is an optional module required only if you are going to use the Video identification during verification.

To enable the module:

  1. Add the module:
    • Swift Package Manager — add the IdensicMobileSDK_VideoIdent library to your target.
    • CocoaPods — add IdensicMobileSDK/VideoIdent dependency into your Podfile.
  2. Add the Background mode capability for your project target and select the Audio, AirPlay and Picture in Picture options. This is required for the video call not to be broken when the application goes into background.

Basic usage

🚧

Attention

Make sure you have configured your verification level and access token before initializing the SDK.

Initialization

To initialize MobileSDK:

  1. Import the framework.
import IdensicMobileSDK
  1. Declare the initialization parameters.
let accessToken = "..." // get the `accessToken` from your backend

As you can see, the only thing you need is an accessToken from your backend. The token points to the verification level that defines the steps of the verification process and indicates an applicant to be verified.

The MobileSDK will work in the production or sandbox environment, depending on which one the accessToken has been generated on.

  1. Instantiate SNSMobileSDK and check if setup succeeded.
let sdk = SNSMobileSDK(
    accessToken: accessToken
)

guard sdk.isReady else {
    print("Initialization failed: " + sdk.verboseStatus)
    return
}

Here you create an SDK instance and ensure that the setup was successful with sdk.isReady. If it happens to fail, you will be able to pinpoint the reason by printing sdk.verboseStatus.

  1. The next important step is to set the tokenExpirationHandler. Typically, the access token is valid for a rather short period of time and when it is expired, you must provide another one. For more information, see Token expiration.
sdk.tokenExpirationHandler { (onComplete) in
    get_token_from_your_backend { (newToken) in
        onComplete(newToken)
    }
}

Most likely, you will then tune up the SDK a bit further by assigning Handlers and Callbacks, and by applying some Configuration and Customization, but that's just an optional feature.

👍

Tip

We know that the requirement to provide the accessToken as an initialization parameter forces you to ask your backend, and due to the async nature of this process, you'll have to build some UI around.

For your convenience, it's possible to postpone the provision of the token until the SDK has been presented.

To do so, you will need to pass an empty string as accessToken at the initialization stage. This way the tokenExpirationHandler will be called immediately after the SDK is appeared up at the time when an activity indicator is displayed.

Presentation

Once setup is done you are ready to present the SDK on the screen.

yourViewController.present(sdk.mainVC, animated: true, completion: nil)

Since SDK contains its own navigation stack, it's required to be presented modally instead of being pushed.

You can also use a shortcut like this.

sdk.present(from: yourViewController)

Or even shorter if it's comfortable for you to present the SDK on the key window root view controller.

sdk.present()

Dismissal

By default, once the applicant is approved, the SDK will be dismissed in 3 seconds automatically. You can adjust this time interval or switch the automatic dismissal off by setting the value of zero.

sdk.setOnApproveDismissalTimeInterval(0)

Also, in case you need to close the SDK programmatically.

sdk.dismiss()

Configuration

Applicant data

For your convenience and if required, you can provide an email and/or phone number to be assigned to the applicant initially.

sdk.initialEmail = "..." // applicant's email
sdk.initialPhone = "..." // applicant's phone number

Preferred documents

For the IDENTITY* steps, it is possible to specify the preferred country and document type to be selected automatically bypassing the DocType Selector screen.

Pay attention that the provided parameters will be applied only if the corresponding combination of country and idDocType is allowed at the step according to the level configuration.

For example:

sdk.preferredDocumentDefinitions = [
    .identity: SNSDocumentDefinition(
        idDocType: "DRIVERS",
        country: "USA"
    )
]