Cordova
Getting Started
Latest release:
Requirements
- Physical devices (Android & iOS)
- Internet connection
- Camera
Installation
It’s always recommended to use the updated version
Step 1: Run the following command in your project terminal:
cordova plugin add shuftipro-cordova-mobile-sdk
Step 2: For iOS: Add camera permission to info.plist
Step 3: For iOS, make sure to add the following post-install hook to your Podfile and install pod on platform/ios main folder.
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
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 client_id and secret_key or access token in auth object.
Basic Auth
Make auth object using client id and secret key
var authObject =
{
auth_type:"basic_auth",
client_id: "xxxxx-xxxxx-xxxxx",
secret_key: "xxxxx-xxxxx-xxxxx"
}
Or
Access Token
Make auth object using access token
var authObject =
{
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.
var configObject =
{
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.
var verificationObject =
{
reference: "uniqueReference",
country: "",
language: "EN",
email: "[email protected]",
callback_url: "http://www.example.com",
redirect_url: "http://www.example.com",
show_consent: 1,
show_results: 1,
verification_mode:"image_only",
show_privacy_policy: 1,
face: {proof: ""},
document: {
supported_types:["passport", "id_card", "driving_license", "credit_or_debit_card"],
name: {
first_name: "",
last_name: "",
middle_name: ""
},
dob: "",
document_number: "",
expiry_date: "",
issue_date: "",
fetch_enhanced_data: "",
gender: "",
backside_proof_required: "0",
},
};
Initialisation
Shufti Pro's mobile SDK can be initialized using the given method and passing auth, config and request objects as the parameters.
cordova.exec(
function(result) {
console.log('ShuftiPro request success:', JSON.stringify(result));
},
function(error) {
console.error('ShuftiPro request error:', result);
},
'shuftiproMobileSDK',
'createRequest',
[verificationObject, authObject, configObject]
);
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
function(result) {
console.log('Shuftipro request success:', result.event);
if (result.event === "verification.accepted") {
// Verification accepted callback
}
else if (result.event === "verification.declined") {
// Verification declined callback
}
else {
// Something else
}
},
The complete list of callback events can be found here.
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 remove the screen from verification flow, you need to provide that parameter to the SDK through request/config object. For instance;
Request Object
"country" : "GB"
"verification_mode" : "image_only"
"allow_online" : "1"
"allow_offline" : "1"
"decline_on_single_step" : "1"
"show_ocr_form" : "0"
"allow_retry" : "0"
You can find the complete detail here
Config Object
"show_requirement_page": true
"base_url": "api.shuftipro.com"
"consent_age": 16
You can find the complete detail here
Localization
Shufti Pro offers users the capability to customise the SDK text according to their preferred language. Merchants can modify the SDK language by specifying the language code in the country parameter within the main request object, such as "language": "en"
Revision History
Date | SDK Versions | Description |
---|---|---|
Dec 19, 2023 | 0.0.2 | Improvement Onsite SDK now offers an enhanced user interface along with improved features for localization, OCR Form, and a Retry Option. |