iOS SDK (Deprecated)
This documentation is for the Standard Version, encompassing foundational features. To access expanded capabilities and the latest advancements, we strongly recommend upgrading to the Enhanced Version
Getting Started
Latest release: version 3.7.4
Requirements
- iOS 13.0 and higher
- Internet connection
- Latest Xcode Version
Resources
- Integration Sample (Swift): Shufti Pro [iOS-SDK](https://github.com/shuftipr o/iOS-SDK)
Integration
SDK Integration Guide
It’s always recommended to use the updated version and run on physical device to get real results.
If you want to run sdk on simulator use this sdk but only for testing purpose.
- Cocoapods
- Swift Package Manager
Make sure your project contains pod file. If it does not, run pod init
command in root of your project directory.
1. Add following pod to your Podfile
pod 'ShuftiPro'
2. Please make sure to add the following post-install hook to your Podfile.
post_install do |installer|
installer.aggregate_targets.each do |target|
target.xcconfigs.each do |variant, xcconfig|
xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
xcconfig_path = config.base_configuration_reference.real_path
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
if ['Socket.IO-Client-Swift', 'Starscream'].include? target.name
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
end
Shufti Pro supports Swift Package Manager for easy integration of the SDK.
To integrate the Shufti Pro SDK with Swift Package Manager, add this repo as a dependency to your project.
Go to File -> Add Package
Paste the URL in the text field.
https://github.com/shuftipro/shuftipro-ios-sdk
Permissions:
Application Info.plist must contain Privacy - Camera Usage Description
, Privacy - Microphone Usage Description
and Privacy - NFC Scan Usage Descriptionkey
with corresponding explanation to end-user about how the app will use these permissions
Basic Usage
Make sure you have obtained authorization credentials before proceeding. You can get client id or secret key and generate access token like this.
Authorization
The following code snippet shows how to use the access token in auth object.
Access Token
Make auth object using access token
let authKeys = [
"auth_type" : "access_token",
"access_token" : "xxxxx-xxxxx-xxxxx"
]
Configuration
The Shufti Pro’s mobile SDKs can be configured on the basis of parameters provided in the config object. The details of parameters can be found here.
let configs = [
"open_webview" : false,
"async" : false,
"dark_mode": false,
"video_kyc": false,
"base_url": "api.shuftipro.com",
"consent_age": 16,
]
Request Object
This object contains the service objects and their settings through which the merchant wants to verify end users. Complete details of service objects and their parameters can be found here.
- 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" : "",
"allow_warnings" : "1",
"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 by using the following 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 process depends on the device's processing power. All the proofs are taken against required services and then a request is made to the server
You can enable native flow by passing false
for open_webview
key in Config
object.
let configs = [
"open_webview" : false, //pass false for verification through native view
]
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 after every service, verification results are shown simultaneously in case of decline, and the user can retry the request.
You can enable hybrid flow by passing true
for open_webview
key in Config
object.
let configs = [
"open_webview" : true, //pass true for verification through hybrid view
]
In both flows, Shufti Pro provides the facility to their customers to tailor the identity verification services according to their needs.
Callbacks
The SDK receives callback events as result, whether the verification journey is completed or left mid-way. The call back is received in following function
shufti.shuftiProVerification(requestObject: dataDictionary, authKeys: authKeys, parentVC: self, configs: configs)
{
(result) in
let reponse = result as! NSDictionary
}
The complete list of callback events can be found here.
Callbacks Handling
All the callbacks can be handled inside the client's calling View/Screen. The response and callback handling code can be seen in the following code snippet
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
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
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 customisation options that will influence the appearance of the mobile SDK.
Verification flow and UI
The complete verification journey is customisable. To skip the screen from verification flow, you need to provide corresponding parameter to the SDK through the request/config object. For instance;
Request Object
"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
"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
"show_requirement_page": true // passing true value to this parameter will show requirement page of Shufti Pro verification.
"base_url": "api.shuftipro.com" // User can pass api.shuftipro.com or us-api.shuftipro.com
"consent_age": 16 // This parameter is use to set age in consent screen.
Colours
The colour of buttons and font can be customised using the following parameters with Shufti Pro's instance.
instance.buttonTextColor = .white
instance.buttonBackgroundColor = .blue
instance.fontColor = .black
Personalization
Shufti Pro provides its users with the facility to personalize the text of the SDK according to their individual requirements. The text of the SDK can be personalize 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 following parameter 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 Description key 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.6.9', :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.aggregate_targets.each do |target|
target.xcconfigs.each do |variant, xcconfig|
xcconfig_path = target.client_root + target.xcconfig_relative_path(variant)
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.base_configuration_reference.is_a? Xcodeproj::Project::Object::PBXFileReference
xcconfig_path = config.base_configuration_reference.real_path
IO.write(xcconfig_path, IO.read(xcconfig_path).gsub("DT_TOOLCHAIN_DIR", "TOOLCHAIN_DIR"))
end
if ['Socket.IO-Client-Swift', 'Starscream', 'NFCPassportReader'].include? target.name
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
end
end
end
end
To check NFC supported documents and countries, please click here.
Nfc verification is allowed only on e-passports under document, document_two and address service only. The NFC service is not available in hybrid view for now.
SDK size
The complete size of Shufti Pro's iOS SDK is 15 MB.
Revision History
Date | SDK Versions | Description |
---|---|---|
Mar 12, 2024 | 3.7.4 | Added support for XCode 15.3 |
Dec 26, 2023 | 3.7.2 | Add support for iOS 17. |
Dec 18, 2023 | 3.7.1 | Added support for XCode 15.2 |
Dec 15, 2023 | 3.7.0 | Improved the invalid request case in hybrid flow of SDK. |
Oct 11, 2023 | 3.6.9 | Changed Changed the response formate of SDK callback Improved the response of user cancelled and permission denied Removed Removed "response" object from callback. |
Sep 25, 2023 | 3.6.8 | Added support for iOS 17. |
Sep 14, 2023 | 3.6.7 | Improve image compression. |
Sep 08, 2023 | 3.6.6 | Added support for XCode 14.3. |
Sep 08, 2023 | 3.6.5 | Added support for XCode 14.2. |
Sep 07, 2023 | 3.6.4 | Added age option on consent screen. |
Aug 31, 2023 | 3.6.3 | Improve auto capture and design of SDK. |
Jul 20, 2023 | 3.6.0 | Added requirement page and improve user experience. |
Jul 03, 2023 | 3.5.8 | Added help sections in iOS SDK. |
May 30, 2023 | 3.5.7 | Improve functionality of mobile SDK. |
May 08, 2023 | 3.5.6 | Reduce SDK size to 15MB. |
May 04, 2023 | 3.5.5 | Reduce SDK size and improve UI. |
Apr 29, 2023 | 3.5.4 | Added new translation phrases in sdk. |
Apr 20, 2023 | 3.5.3 | Added iOS 11 support. |
Apr 19, 2023 | 3.5.2 | Improve user experience of SDK. |
Apr 11, 2023 | 3.5.1 | Enhance UI and improve user experience. |
Apr 10, 2023 | 3.5.0 | Improve phrase of supported type screen. |
Mar 28, 2023 | 3.4.8 | Handled camera permissions if denied from settings |
Mar 17, 2023 | 3.4.7 | Updated list of countries. |
Mar 16, 2023 | 3.4.6 | Improve full screen preview of captured proof. |
Jan 25, 2023 | 3.4.5 | Added video KYC service inside SDK in which users can verify identity through video calls with the Shufti Pro agent. |
Jan 20, 2023 | 3.4.4 | Improve threads in camera screen. |
Jan 16, 2023 | 3.4.3 | Tap to focus feature is added to camera |
Jan 03, 2023 | 3.4.1 | The size of framework file has been reduced, making it easier and convinent to use. |
Sep 12, 2022 | 3.4.0 | Improved UI for NFC verification and added animated instruction. |
Aug 25, 2022 | 3.3.9 | Improve native to web callback issue and added the option to switch between visual and textual instructions. |
Aug 15, 2022 | 3.3.8 | Improved instructions for face verification. |