Skip to main content

IncdOnboarding SDK Usage

Requirements:

  • iOS 11.0+
  • Xcode 13+

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.

2. Configure the Onboarding session

Firstly, you should create an instance of IncdOnboardingSessionConfiguration, which provides a configuration of onboarding session:

let sessionConfig = IncdOnboardingSessionConfiguration()

You can optionally customize the onboarding session by providing these parameters:

  • Parameter regionCode: Specify the user's region
  • Parameter queue: Specify the queue which the user will enter once the flow is completed. If none specifed user goes to default queue.
  • Parameter configurationId: Specify flow id from the dashboard in order to use configurations applied to that flow. Note that you still have to add onboarding steps via IncdOnboardingFlowConfiguration in order to display onboarding flow to the user.
  • Parameter validationModules: List of Onboarding Validation modules to be taken into account for user scoring and approval. By default it is .id, .liveness, .faceRecognition
  • Parameter customFields: Provide a list of custom fields that will be stored for this session
  • Parameter interviewId: ID of the onboarding session. Specify in order to resume existing onboarding session.
  • Parameter token: Token of the onboarding session. Specify in order to resume existing onboarding session.
  • Parameter externalId: Id that is used outside of Incode Omni platform. If a session with the same externalId already exists, it will be resumed instead of creating a new one.

3. Configure the Onboarding flow

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

let flowConfig = IncdOnboardingFlowConfiguration()
flowConfig.addIdScan()
flowConfig.addSelfieScan()
flowConfig.addFaceMatch()

The steps will be executed in the order you added them to the flow config.

4. Start the Onboarding

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

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

You should provide your UIViewController instance, previosuly created IncdOnboardingSessionConfiguration, IncdOnboardingFlowConfiguration 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)

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.

2. Setup onboarding session

Before calling other Onboarding SDK components it is nececessary to setup an onboarding session.


IncdOnboardingManager.shared.setupOnboardingSession(sessionConfig: IncdOnboardingSessionConfiguration()) { (sessionResult) in
// Setting up the onboarding session is completed
if sessionResult.result == .success {
// Its now safe to start to call other methods
...
}

}

3. Show Onboarding Sections or call other SDK methods

After onboarding session is setup 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.

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

IncdOnboardingFlowConfiguration flowConfig  = IncdOnboardingFlowConfiguration()
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, sectionTag: "MySection", 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)

Call 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`
}

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
}

Capture Only

Full guide for Capture Only SDK mode is available 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.