Skip to main content

iOS SDK

Getting Started

Latest release: version 3.4.5

Requirements

  • iOS 13.0 and higher
  • Internet connection
  • The Xcode version should be the latest

Resources

  • Integration Sample (Swift): Shufti Pro iOS-SDK

Installation

tip

It’s always recommended to use the updated version

  1. Add this pod into your Podfile.
pod 'ShuftiPro', :tag => '3.4.5', :git => "https://github.com/shuftipro/iOS-binary-pod"
  1. Please make sure to add the following post-install hook to your Podfile.
post_install do |installer|
installer.pods_project.targets.each do |target|
if ['lottie-ios', 'Socket.IO-Client-Swift', 'Starscream'].include? target.name
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
end

Basic Usage

Note

Make sure you have obtained the client id and secret key or access token before proceeding

Authorization

Shufti Pro provides two types of authorization to its users. The following shows the code snippet of how to use the authorization keys to authenticate the SDK.

  • Basic Auth

    Make auth object using client id and secret key
let authKeys = [ 
"auth_type" : "basic_auth",
"client_id" : "xxxxx-xxxxx-xxxxx",
"secret_key": "xxxxx-xxxxx-xxxxx"
]
  • Access Token

    Or make auth object using access token
let authKeys = [
"auth_type" : "access_token",
"access_token" : "xxxxx-xxxxx-xxxxx"
]
info

You can get client id or secret key and generate access token like this

Configuration

The Shufti Pro’s mobile SDKs can be configured on the basis of parameters provided in the config object. Make config object

let configs = [
"open_webview" : false,//pass true for verification through hybrid view
"async" : false,
"dark_mode": false,
"video_kyc": false,
]

Config object parameters are explained here.

Request Object

This object contains the service objects and their settings through which the merchant wants to verify end users. Import Shufti Pro

import ShuftiPro

Request Object

let requestObject: [String: Any] = [ 
"reference": "Unique reference",
"country": "",
"language": "EN",
"email": "[email protected]",
"callback_url": "http://www.example.com",
"show_results" : "",
"show_consent" : "",
"show_privacy_policy" : "",
"verification_mode": "image_only",
"face": ["proof": ""],
"document": [
"proof": "",
"additional_proof" :"",
"supported_types": [
"passport",
"id_card"
],
"name": [
"first_name": "",
"last_name": ""
],
"backside_proof_required": "0",
"dob": "",
"document_number": "",
"expiry_date": "",
"issue_date": ""
],
"address": [
"proof": "",
"full_address": "",
"name": [
"first_name": "",
"last_name": ""
],
"supported_types": [
"id_card",
"utility_bill",
"bank_statement"
]
],
"consent":[
"proof" : "",
"text" : "my consent note",
"supported_types" :[
"printed",
"handwritten"
]
]
]

Initialisation

Shufti Pro's mobile SDK can be initialized using the given method and passing auth, config and request objects as the parameters.

let instance = ShuftiPro()
instance.shuftiProVerification(requestObject: "your-request-object", authKeys: "authentication-keys-object",
parentVC: your viewController from where you want to open ShuftiPro,
configs: "configuration-object"){(result) in
print(result) // Callback response for verification verified/declined
let response = result as! NSDictionary
if response.value(forKey: "event") as? String == "verification.accepted" {
// Verified: Do something
}else{
// Declined: Do something
}
}

Verification Types

Native Flow

In the native verification flow, the end-user interacts with the native mobile SDK. The native flow of verification tends to be much faster since the whole app depends on the device's processing power for the verification process. Also, all the proofs are taken for all services in native flow first and then and only then, is a request made to the server in the form of JSONObject.
You can enable native flow by passing false for open_webview key in Config object.

Config.put("open_webview",false);

Hybrid Flow

The hybrid verification flow includes mobile verifications on a web view built on HTML 5 that will show the verification process to the end user. End-user provides the information in the online customer onboarding process. In hybrid flow, proofs are uploaded as every service is performed, verification results are shown simultaneously in case of decline, and the user can retry the request.
You can enable native flow by passing true for open_webview key in Config object.

Config.put("open_webview",true);
info

In both flows, Shufti Pro provides the facility to their customers to tailor the identity verification services according to their needs.

SDK Flow

Callbacks

Callbacks are received whenever the SDK is terminated or closed, whether after request completion or if the verification journey is left mid-way. The call backs are received in

(result) in 
print(result) // Callback response for verification verified/declined
let reponse = result as! NSDictionary

Following is the list of callbacks we receive in the above function.

KeysValuesDescription
Eventrequest.unauthorizedThe auth header is not correct and, client id/secret key may be invlaid.
Eventrequest.pendingThis event is returned for all on-site verifications until the verification is completed or timeout.
Eventverification.acceptedVerification accepted callback
Eventverification.declinedVerification declined callback
Eventpermission.deniedThis event is returned if the user did not give camera and other permissions to sdk.
Eventrequest.timeoutThis will occur if request has timed-out
Eventverification.cancelledThis callback is returned when verification is cancelled midway by the end user
Eventrequest.receivedThis event states that the verification request has been received and is under processing
Eventrequest.invalidThe request invalid event occurs when the parameters specified in the request payload are not in the correct format.
ErrorInternet Connection ErrorThis callback is returned in case of lost internet connectivity
info

You can check complete response of shuftipro from here

Callbacks Handling

All the callbacks can be handled inside the client's calling activity. The response and callback handling can be seen in the image below:

On SDK Completion

let reponse = result as? NSDictionary
if reponse?.value(forKey: "event") as? String == "verification.accepted" {
// Verification Accepted Callback
}
else if reponse?.value(forKey: "event") as? String == "verification.declined"{
// Verification Declined Callback
}
else if reponse?.value(forKey: "event") as? String == "request.received"{
// This event states that the verification request has been received and is under processing.
}
else if reponse?.value(forKey: "event") as? String == "request.pending"{
// This event is returned for all on-site verifications until the verification is completed or timeout.
}

On SDK Unauthentication

else if reponse?.value(forKey: "event") as? String == "request.unauthorized"{
// This event occurs when the auth header is not correct and, client id/secret key may be invlaid.
}

On SDK Error


else if reponse?.value(forKey: "event") as? String == "request.invalid"{
// The request invalid event occurs when the parameters specified in the request payload are not in the correct format.
}
else if reponse?.value(forKey: "event") as? String == "request.timeout"{
// This will occur if request has timed-out.
}
else if reponse?.value(forKey: "event") as? String == "permission.denied"{
// This event is returned if the user did not give camera and other permissions to sdk.
}
else if reponse?.value(forKey: "event") as? String == "verification.cancelled"{
//This event occurs when the end-user does not agree to the terms and conditions and also occur if in-between user cancel verification process.
}

Customisation

ShuftiPro supports a set of customization options that will influence the appearance of the mobile SDK.

Verification flow and UI

The complete verification journey is customisable. To remove the screen from verification flow, you need to provide that parameter to the SDK through request/config object. For instance;

Request Object

"show_consent" : "0" // providing this parameter 0 value will hide the verification consent screen

"country" : "GB" // providing a value to this parameter will not ask the end user to provide his country

"verification_mode" : "image_only" // "image_only" or "video_only" values will allow you to avoid mode selection at real-time

"show_privacy_policy" : "0" // value will remove the privacy policy content shown at result screen

"allow_online" : "1" // 1 value will ask the user to capture real time proofs(image or video) depending upon verification mode

"allow_offline" : "1" // 1 value will ask the user to upload proofs(image or video) depending upon verification mode

"decline_on_single_step" : "1" // this parameter will work with onsite flow(open_webview : true). This will show continue the journey only if pervious step is successfully verified

"show_feedback_form" : "1" // this parameter will work with onsite flow(open_webview : true). 1 value will ask the user for its feedback at the end of verification

// Service Level Parameters

"supported_types" : [id_card] // providing a single value to this parameter will not ask the user for document type

"show_ocr_form" : "1" // this parameter will work with onsite flow(open_webview : true). 1 value will show the OCR form to the user

Config Object

"asyncRequest": "true" // passing true value to this parameter will not show result screen to the user and will just return the callback on request completion

Colours

The colour of buttons and font can be customized using the following parameters with Shufti Pro's instance.

instance.buttonTextColor = .white 
instance.buttonBackgroundColor = .blue
instance.fontColor = .black

Localization

Shufti Pro provides its users with the facility to translate the SDK entirely into their desired language or customize the text of the SDK according to their requirements. The text of the SDK can be customized by adding your own Localizable.strings file to your project using a standard iOS localization mechanism. To change a specific text, override the corresponding key in this Localizable.strings file.

Dark mode

To apply dark theme/mode in SDK, initialize the SDK with provided parameters in the config object.

"dark_mode" : true,

NFC verification

Near Field Communication (NFC) is a set of short-range wireless technologies. NFC allows sharing of small data payloads between an NFC tag and an NFC-supported device. NFC Chips found in modern passports, and similar identity documents contain additional encrypted information about the owner. This information is very useful in verifying the originality of a document. NFC technology helps make the verification process simple, quicker and more secure. This also provides the user with contactless and input less verification. ShuftiPro's NFC verification feature detects MRZ from the document to authenticate NFC chips and retrieve data from it, so the authenticity and originality of the provided document can be verified.

Installation

Step 1 Application Info.plist must contain a Privacy - Camera Usage Description, Privacy - Microphone Usage Description and Privacy - NFC Scan Usage Descriptionkey with an explanation to the end-user about how the app uses this data.

Step 2 And Open your Info.plist file as Source Code add these lines inside the dict tag.

<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key> 
< array>
< string>00000000000000</ string>
< string>A0000002471001</ string>
</ array>

Step 3 In your Project target, add under the Signing and Capabilities section, tap on Capabilities and add Near Field Communication Tag Reading.For more guidance watch this guided image here

Step 4 Add this dependency into your project's Podfile.

pod 'ShuftiProNFC', :tag => '3.4.5', :git => "https://github.com/shuftipro/ios-nfc-binary-pod.git"

Step 5 Please make sure to add the following post-install hook to your Podfile.

post_install do |installer|
installer.pods_project.targets.each do |target|
if ['lottie-ios', 'Socket.IO-Client-Swift', 'Starscream','NFCPassportReader'].include? target.name
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
end
Note

Nfc verification is allowed only on e-passports under document, document_two and address service only. The NFC service is not available in the hybrid web view for now.

SDK size

The complete size of Shufti Pro's android SDK is 15.1 MB.

Changelog

SDK VersionsChanges
3.4.5
  • Added video KYC service inside SDK in which users can verify identity through video calls with the shuftipro agent.
3.4.4
  • Fix threads issues in camera screen.
3.4.3
  • Tap to focus feature is added to camera
  • Image quality while capturing proofs, is increased
3.4.1
  • Reduce framework file
    • The size of framework file has been reduced, making it easier and convinent to use.
  • Fix camera permission denied callback
    • A call back has been added when end user denies the permissions required for SDK.
3.4.0
  • Improved UI for NFC verification.
    • Animated instruction(gif) for NFC was improved
    • Data representation was improved
  • Resolve the white line issue on the face preview
    • A very thin white line appeared on the face captured proof, this issue is now fixed.
3.3.9
  • Fix native to web callback issue
    • While navigating from native to web flow, the callback gets lost.
  • Added the option to switch between visual and textual instructions..
3.3.8
  • Improved instructions for face verification
    • More accurate instructions were added in image form