Get started with iOS SDK
Latest release: Version 1.33.1 (Changelog)
Requirements
- Xcode 15.2+
- iOS 12.0 or later
- VideoIdent module requires iOS 12.2+
- MRTDReader module requires iOS 13+
Attention
Make sure bitcode is disabled for your project.
Resources
- IdensicMobileSDK iOS Demo — a demo project in Swift.
- sample.swift — Swift sample code. Feel free to use it as a boilerplate.
- faceAuthActions-sample.swift — sample code for Face Auth actions handling.
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.
CocoaPods
- 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, VideoIdent and EID.
- Add
platform :ios, '12.0'
source 'https://cdn.cocoapods.org/'
source 'https://github.com/SumSubstance/Specs.git'
target 'YourApp' do
pod 'IdensicMobileSDK'
# pod 'IdensicMobileSDK/MRTDReader'
# pod 'IdensicMobileSDK/VideoIdent'
# pod 'IdensicMobileSDK/EID'
# any other dependencies
end
- 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>
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:
- Add the module:
- Swift Package Manager — add the
IdensicMobileSDK_MRTDReader
library to your target. - CocoaPods — add the
IdensicMobileSDK/MRTDReader
dependency into yourPodfile
.
- Swift Package Manager — add the
- Turn on the
Near Field Communication Tag Reading
capability for your project target. - 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:
- Add the module:
- Swift Package Manager — add the
IdensicMobileSDK_VideoIdent
library to your target. - CocoaPods — add
IdensicMobileSDK/VideoIdent
dependency into yourPodfile
.
- Swift Package Manager — add the
- Add the
Background mode
capability for your project target and select theAudio, AirPlay
andPicture in Picture
options. This is required for the video call not to be broken when the application goes into background.
eID
The EID
is an optional module required only if you are going to use "eID Verification" during the verification flow.
To enable the module:
- Add the module:
- Swift Package Manager — add the
IdensicMobileSDK_EID
library to your target. - CocoaPods — add
IdensicMobileSDK/EID
dependency into yourPodfile
.
- Swift Package Manager — add the
- Turn on the
Near Field Communication Tag Reading
capability for your project target. - Update the application
Info.plist
file as follows:
<key>NFCReaderUsageDescription</key>
<string>Let us scan the eID card to verify your identity</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>A0000002471001</string>
<string>E80704007F00070302</string>
</array>
Basic usage
Attention
Make sure you have configured your verification level and access token before initializing the SDK.
Initialization
To initialize MobileSDK:
- Import the framework.
import IdensicMobileSDK
- 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.
- 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
.
- 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 thetokenExpirationHandler
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"
)
]
Updated about 1 month ago