Mobile SDK integration guide
Overview of flow

Supported SDKs
We natively support iOS, Android, React Native, Flutter, and Cordova. You will find the sample apps for our native SDKs below:
Requirements
Swift 5.
iOS 13 and above.
Xcode 13 and above.
Getting started
Get started with our user guide for an overview of our core platform and its multiple features, or browse the API reference for fine-grained documentation of all our services.
1. Install the SDK
CocoaPods
Before using the ComplyCube SDK, install the CocoaPods plugin by running the following command in your terminal:
sudo gem install cocoapods
Add plugin repos and install the pod using your
Podfile
:source 'https://github.com/CocoaPods/Specs.git' … platform :iOS, ’13.0’ target ‘YourApp’ do … pod 'ComplyCubeMobileSDK' end post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |build_configuration| build_configuration.build_settings['ENABLE_BITCODE'] = 'NO' build_configuration.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES' build_configuration.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.1' build_configuration.build_settings['ARCHS'] = ['$(ARCHS_STANDARD)', 'x86_64'] build_configuration.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = ['arm64', 'arm64e', 'armv7', 'armv7s'] build_configuration.build_settings['GENERATE_INFOPLIST_FILE'] = 'YES' end end end
Application permissions
Our SDK uses the device camera and microphone for capture. You must add the following keys to your application Info.plist
file.
NSCameraUsageDescription
<key>NSCameraUsageDescription</key>
<string>Used to capture facials biometrics and documents</string>
NSMicrophoneUsageDescription
<key>NSMicrophoneUsageDescription</key>
<string>Used to capture video biometrics</string>
2. Create a client
Before launching the SDK, your app must first create a client using the ComplyCube API.
A client represents the individual you need to perform identity verification checks on. This must be done on your mobile app backend server, not the mobile app itself.
Example request
curl -X POST https://api.complycube.com/v1/clients \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"type": "person",
"email": "[email protected]",
"personDetails":{
"firstName": "John",
"lastName" :"Doe"
}
}'
Example response
The response will contain an id (the Client ID), which is required for the next step.
{
"id": "5eb04fcd0f3e360008035eb1",
"type": "person",
"email": "[email protected]",
"personDetails": {
"firstName": "John",
"lastName": "Doe"
},
"createdAt": "2023-01-01T17:24:29.146Z",
"updatedAt": "2023-01-01T17:24:29.146Z"
}
3. Generate an SDK token
SDK Tokens enable clients to send personal data securely from your mobile app to ComplyCube. Learn more about our SDK Token endpoint.
Example request
curl -X POST https://api.complycube.com/v1/tokens \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"clientId":"CLIENT_ID",
"appId": "com.complycube.SampleApp"
}'
Example response
{
"token": "<CLIENT_TOKEN>"
}
4. Prepare the stages
Set up the stages you wish to include in your flow.
let documentStage = DocumentStageBuilder()
.setAllowedDocumentTypes(types: [
.passport,
.nationalIdentityCard(),
])
.useLiveCaptureOnly(enable: false)
.build()
5. Initialize an SDK flow
You can now initialize a flow by setting the SDK Token, Client ID, and the flow stages. The sequence of stages you specify determines the order in which your client sees those stages.
let sdk = ComplyCubeMobileSDK.FlowBuilder()
.withSDKToken("SDK_TOKEN")
.withClientId("CLIENT_ID")
.withStages([documentStage, selfieStage])
.start(fromVc: self)
var clientAuth = ClientAuth("SDK_TOKEN", "CLIENT_ID")
6. Perform checks
Using the results returned in the onSuccess
callback, you can trigger your mobile backend to run the necessary checks on your client.
For example, use the result of a selfie and document capture as follows:
result.documentId
to run a Document Check.result.documentId
andresult.livePhotoId
to run an Identity Check.
Example request for a Document Check
curl -X POST https://api.complycube.com/v1/checks \
-H 'Authorization: <YOUR_API_KEY>' \
-H 'Content-Type: application/json' \
-d '{
"clientId":"CLIENT_ID",
"type": "document_check",
"documentId":"DOCUMENT_ID"
}'
7. Retrieve results
Your mobile backend can retrieve all check results using our API.
All our checks are asynchronous. If you have set up webhooks as described in our webhooks guide, you will be notified once a check completes.
To retrieve the check results, you can perform a get check request.
Example request
curl -X GET https://api.complycube.com/v1/checks/{:checkId} \
-H 'Authorization: <YOUR_API_KEY>'
Stages
Each stage in the flow can be customized to create the ideal journey for your clients.
The snippet below demonstrates how to set up a customized flow using the ComplyCube Mobile SDK.
Learn more about our Mobile SDK stages.
let sdk = ComplyCubeMobileSDK.FlowBuilder()
.withSDKToken("SDK_TOKEN")
.withClientId("CLIENT_ID")
.withStages([
WelcomeStageBuilder().build(),
UserConsentStageBuilder().build(),
DocumentStageBuilder().build(),
BiometricStageBuilder().build(),
AddressCaptureStageBuilder().build(),
ProofOfAddressBuilder().build(),
])
.withEnableCompleteScreen(...)
.withLanguage(...)
.withLookAndFeel(...)
.withEventHandler(...)
.withCallbackHandler(...)
.start(fromVc: self)
Look and feel
The SDK allows you to set colors to match your existing application or brand. You can customize the colors by setting the relevant values when building your flow.
Learn more about our appearance properties.
Creating a custom appearance
Before initiating the flow, create your own custom design and integrate it into your Flow Builder.
let ccLookAndFeel = LookAndFeel()
ccLookAndFeel.primaryButtonBgColor = .green
ccLookAndFeel.uiInterfaceStyle = .dark //can also be .light or .inherited
Applying your custom appearance
Set the custom appearance that you have created using the Flow Builder.
let sdk = ComplyCubeMobileSDK.FlowBuilder()
.withLookAndFeel(ccLookAndFeel)
.start(fromVc: self)
Appearance properties
primaryButtonBgColor
Primary action button background color.
primaryButtonPressedBgColor
Primary action button pressed background color.
primaryButtonTextColor
Primary action button text color.
primaryButtonBorderColor
Primary action button border color.
secondaryButtonBgColor
Secondary button background color.
secondaryButtonPressedBgColor
Secondary action button pressed background color.
secondaryButtonTextColor
Secondary action button text color.
secondaryButtonBorderColor
Secondary action button border color.
documentTypeSelectorBgColor
Document type selection button color.
documentTypeSelectorBorderColor
Document type selection button border color.
documentTypeSelectorTiteTextColor
Document type selection title text color.
documentTypeSelectorDescriptionTextColor
Document type selection description text color.
documentTypeSelectorIconColor
Document type selection icon color.
bodyTextColor
Screen body text color.
linkButtonTextColor
Links color.
headingTextColor
Title heading text color.
subheadingTextColor
Subheading text color.
infoPanelTitleColor
Information panel title color.
infoPanelDescriptionTextColor
Information panel description text color.
infoPanelBgColor
Information panel background color.
infoPanelIconColor
Information panel icon color.
errorPanelTitleColor
Error panel title color.
errorPanelDescriptionTextColor
Error panel description text color.
errorPanelBgColor
Error panel background color.
errorPanelIconColor
Error panel icon color.
cameraButtonBgColor
Camera capture button background color.
uiInterfaceStyle
Set the SDK to use dark mode, light mode, or system Inherited.
Localization
The SDK provides the following international language support:
Arabic -
ar
🇦🇪Chinese (Simplified) -
zh
🇨🇳Chinese (Traditional) -
hk
🇨🇳Dutch -
nl
🇳🇱English -
en
🇺🇸French -
fr
🇫🇷German -
de
🇩🇪Hindi -
hi
🇮🇳Indonesian -
id
🇮🇩Italian -
it
🇮🇹Japanese -
ja
🇯🇵Korean -
ko
🇰🇷Norwegian -
no
🇳🇴Polish -
po
🇵🇱Portuguese -
pt
🇵🇹Spanish -
es
🇪🇸Swedish -
sv
🇸🇪Thai -
th
🇹🇭Vietnamese -
vi
🇻🇳
Result handling
To handle results you must implement the success, cancelled or error callbacks.
Upon an "on success" callback, you can initiate check requests directly from your mobile app backend server. This can be done using the IDs of the uploaded resources, returned in the result parameter.
extension ViewController: ComplyCubeMobileSDKDelegate {
func onSuccess(_ result: ComplyCubeResult) {
/*
Handling successful results:
Our default flow includes three components: an Identity Document,
a Selfie (Live Photo), and a Proof of Address. Upon successful
completion, the 'result' parameter will contain `documentIds`and `livePhotoId`
*/
print("The flow has completed - here are the ID's returned")
}
func onError(_ error: ComplyCubeError) {
// Handle errors
print("An error has occurred")
}
func onCancelled(_ error: ComplyCubeError) {
// Handle cancellations
print("The user has cancelled the flow or not accepted the terms")
}
}
If the SDK experiences any issues, the "on error" callback will return a ComplyCubeError
. Learn more about our Mobile SDK error codes.
If the client exits the SDK flow before completion, the description provided by the "on cancelled" callback will specify the reason.
Events tracking
The SDK tracks an array of events across the various stages of a flow.
If you want to implement your own user tracking, the SDK enables you to insert your custom tracking code for the tracked events.
To incorporate your own tracking, define a function and apply it using withEventHandler
when initializing the FlowBuilder
:
let sdk = ComplyCubeMobileSDK.FlowBuilder()
.withEventHandler({ (event: Event) -> Void in
// Insert custom user tracking code here
})
Token expiry handling
If you want to automatically manage token expiration, you can use a callback function to generate a new token and seamlessly continue the process with it.
let sdk = ComplyCubeMobileSDK.FlowBuilder()
.withTokenExpiryHandler({ () -> String in
// Insert custom token renewal code here
})
Last updated
Was this helpful?