Skip to main content

IncdOnboarding SDK Usage

Requirements:

  • iOS 11.0+
  • Xcode 12+

IncdOnboarding SDK can be used in three ways - Standard, Advanced and Capture only. Standard mode starts the Onboarding flow that consists of specified steps and validates user inputs along the way. Advanced mode enables you to fully customize the experience of the flow, ie. by splitting it into multiple sections, adding your own custom screens between some of the steps etc. Capture only mode enables you to just retrieve captured images during ie. ID or Selfie scan, without doing any validations such as ID validation, Face recognition and Liveness detection.

Standard

1. Initialize IncdOnboarding SDK

Add the following line of code to your AppDelegate class:

IncdOnboardingManager.shared.initIncdOnboarding(url: url, apiKey: apiKey)

url and apiKey will be provided to you by Incode. Optionally, token can be used instead of an apiKey. If you're running the app on a simulator, please set the testMode parameter to true.

Review the IncdOnboardingManager specification here.

2. Configure Onboarding Flow

Firstly, you should create an instance of IncdOnboardingConfiguration:

let config = IncdOnboardingConfiguration()

Optionally, you can specify user's region and queue to which the user will go in the video conference step of the flow.

Depending on your needs you should specify the steps you want to include, ie.:

config.addIdScan()
config.addSelfieScan()
config.addFaceMatch()

The steps will be executed in the order you added them to the config. Review the IncdOnboardingConfiguration specification here.

3. Start the Onboarding flow

In your UIViewController class where you want to start the onboarding flow you should call startOnboarding function:

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startOnboarding(config: config, delegate: self)

You should provide your UIViewController instance, previosuly created IncdOnboardingConfiguration and a delegate that conforms to IncdOnboardingDelegate protocol that will be notified about updates from IncdOnboarding SDK as the user goes through the flow.

  
// Called when front Id Scan is completed
func onIdFrontCompleted(_ result: IdScanResult)

// Called when back Id Scan is completed
func onIdBackCompleted(_ result: IdScanResult)

// Called when process ID step is completed.
func onIdProcessed(_ result: IdProcessResult)

// ...

// Called when Onboarding flow is finished successfully
func onSuccess()

// Called when some unexpected error occured during Onboarding flow
func onError(_ error: IncdFlowError)

Review the IncdOnboardingDelegate specification here.

Advanced flow SDK mode

Advanced flow SDK mode enables you to fully customize the experience of the flow, ie. by splitting Onboarding flow into multiple sections, adding your own custom screens between some of the steps etc.

1. Initialize IncdOnboarding SDK

Add the following line of code to your AppDelegateclass:

IncdOnboardingManager.shared.initIncdOnboarding(url: url, apiKey: apiKey)

url and apiKey will be provided to you by Incode. Optionally, token can be used instead of an apiKey. Optionally disable logs, by providing false for loggingEnabled parameter.

Review the IncdOnboardingManager specification here.

2. Create new onboarding session

Before calling other Onboarding SDK components it is nececessary to create a new onboarding session. Besides creating a config, it may be necessary to specify a list of OnboardingValidationModule items depending on the modules you would to like use later on.

This example will include default validation modules that consists of ID Validation, Liveness check and Face Recognition.


IncdOnboardingManager.shared.createNewOnboardingSession(config: IncdOnboardingConfiguration()) { (sessionResult) in
// Creating new Onboarding session is completed
if sessionResult.result == .success {
// Its now safe to call individual Onboarding SDK components
...
}

}

3. Show Onboarding Sections or individual Onboarding SDK components

After the new onboarding session is created you can show Onboarding SDK components based on your need, here's some examples what you can do inside your UIViewController classes where you would like to show Onboarding SDK components.

Review the IncdOnboardingManager specification here.

For each of the steps you can optionally provide a specific interviewId in order to specify a different onboarding session than the most recent one which will be used by default.

Start Onboarding section

If you would like to show multiple steps sequentially, you can specify which ones and their order by creating IncdOnboardingFlowConfiguration object:

IncdOnboardingFlowConfiguration flowConfig  = IncdOnboardingFlowConfiguration(flowTag: "myFlow")
flowConfig.addIdScan()
flowConfig.addFaceScan()

After you've created the flow configuration, you need to call startOnboardingSection to start the flow:

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startOnboardingSection(flowConfig: flowConfig, delegate: self)

Once the section is completed you'll get notified through the delegate and its onOnboardingSectionCompleted function:

func onOnboardingSectionCompleted(_ flowTag: String) {
print("onOnboardingSectionCompleted")
// Show custom UI, create and show another Onboarding section or individual screen
}

Separated Front and Back ID Scan

If you would like to scan the front side of the ID separately from the back side, you need to:

  1. Specify ScanSide parameter:
firstSection.addIdScan(scanStep: .front)
secondSection.addIdScan(scanStep: .back)
  1. Add ID Process module (this step is not required if scanStep is .both)
thirdSection.addIdProcess()

Note: firstSection, secondSection and thirdSection are separated to make an example. They can also be one section but after IdProcess no more scanning will be possible.

Results will be returned in the same way as before, via:

  
// Called when front Id Scan is completed
func onIdFrontCompleted(_ result: IdScanResult)

// Called when back Id Scan is completed
func onIdBackCompleted(_ result: IdScanResult)

// Called when process ID step is completed.
func onIdProcessed(_ result: IdProcessResult)

Show individual Onboarding SDK components

If you would like to show a single step, ie. do a geolocation only, you can call use the API to call individual Onboarding SDK components. To start the geolocatiion:

IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.geolocation() { (result) in
// geolocation is completed, result is of type `GeolocationResult`
}

To see the full list of available individual API calls please review the IncdOnboardingManager specification here.

4. Finish the session

Once you're done with all the steps needed from IncdOnboarding SDK it is necessary to flag this session as finished.

To do so you need to call finishFlow:

IncdOnboardingManager.shared.finishFlow() { success, error in 
// Session is now flag as finished
}

Review the IncdOnboardingManager specification here.

Capture only

Capture only mode should be used in case you would just like to fetch captured ID and Selfie images, without doing any validations such as ID validation, Face recognition and Liveness detection. ID and Selfie Scan are the only supported modules in this mode, and all the processing inside these modules is being done locally.

1. Initialize IncdOnboarding SDK

Add the following line of code to your AppDelegate class:

IncdOnboardingManager.shared.initIncdOnboarding(url: url, apiKey: apiKey)

url and apiKey will be provided to you by Incode. Optionally disable logs, by providing false for loggingEnabled parameter.

Review the IncdOnboardingManager specification here.

2. Enable Capture only mode

IncdOnboardingManager.shared.sdkMode = .captureOnly

3. Start capturing data

To start the front ID capture, use following function:

IncdOnboardingManager.shared.presentingViewController = self
let flowConfig = IncdOnboardingFlowConfiguration(flowTag: "idFront")
flowConfig.addIdScan(idType: .id, scanStep: .front)
IncdOnboardingManager.shared.startOnboardingSection(flowConfig: flowConfig, delegate: self)

Result will be returned via delegate method:

func onIdFrontCompleted(_ result: IdScanResult)

IdScanResult will contain captured image and other data.

To start the Selfie capture, use following function:

let flowConfig = IncdOnboardingFlowConfiguration(flowTag: "selfie")
flowConfig.addSelfieScan()
IncdOnboardingManager.shared.startOnboardingSection(flowConfig: flowConfig, delegate: self)

Result will be returned via delegate method:

func onSelfieScanCompleted(_ result: SelfieScanResult)

SelfieScanResult will contain captured selfie image.

Review the full specification here.

Simulator Support:


To enable simulator support, when initializing the IncdOnboardingManager using the initIncdOnboarding(url:apiKey:token:loggingEnabled:testMode:_:) method, set the testMode parameter to true.

On the simulator, onboarding modules which require use of the device camera will show a black or grey background instead of the camera preview. The modules will only last for 2 seconds before returning .simulatorDetected and then moving on to the next module.

Background conference support

  • In order to enable conference background mode, OpenTok requires a key-value pair to be added to your app. In the Info.plist file for your app, set up the background mode permissions as described in the Apple documentation for creating VoIP apps. The key is UIBackgroundModes. Do add the audio value to this dictionary.