TrustVision SDK is an iOS SDK for TrustVision Engine. It provides these features:
<key>NSCameraUsageDescription</key>
<string>Open camera</string>
pod 'TensorFlowLiteSwift', '~> 2.4.0'
pod 'PromiseKit', '~> 6.8'
pod 'CocoaLumberjack/Swift'
Those lines are added at the end of podfile
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
end
end
end
Embed & Sign
CocoaLumberjack.framework
PromiseKit.framework
Do Not Embed
TensorFlowLite.framework
TensorFlowLiteC.framework
Validate Workspace
in Build Settings
SWIFT_VERSION
)-lc++
and -ObjC
in Other linker flags
The SDK provides some built in Activities example activity to capture id, selfie, liveness...
Initialize the sdk
TrustVisionSdk.shared.initialize(clientSettingsJsonString: nil, languageCode: "vi")
Options:
String
. The jsonConfigurationByServer is optional but recommended.
It's the setting specialized for each client from TS server.
It's the response json string get by API https://ekyc.trustingsocial.com/api-reference/customer-api/#get-client-settings.
When it's null or unmatched with the expected type then the default setting in the SDK will be used.String
. Language code. vi
or en
Allow user to change the sdk language after initialization
TrustVisionSdk.shared.changeLanguageCode(languageCode: String)
TrustVisionSdk.shared.getLanguageCode() -> String?
TrustVisionSdk.shared.getSupportedLanguageCodes() -> []
The id capturing activity will show the camera to capture image, preview the image. To start the id capturing activity.
let config = TVIdCardConfiguration(
cardType: selectedCardType,
cardSide: TVIdCardConfiguration.TVCardSide.front,
isSoundEnable: false,
isReadBothSide: false,
skipConfirmScreen: false,
isEnablePhotoGalleryPicker: false)
Options:
TVCardType
. List of supported cards can be found by let cardTypes: [TSCardType] = try TrustVisionSdk.getCardTypes()
TVCardSide
. Card side to captureBool
. Sound should be played or notBool
. If true then the sdk will capture both side if possible; otherwise, then the card side defined in cardSide will be usedBool
. Skip id capturing confirmation screen nor notBool
. Allow user select id card image from phone gallerylet vc = TrustVisionSdk.shared.startIdCapturing(configuration: config, success: { (result) in
}, failure: { (error) in
}, cancellation: {
// sdk is canceled
})
where:
TVIdCardConfiguration
TVDetectionResult
. Use the following fields:FailureCallback
CancellationCallback
Use this API https://ekyc.trustingsocial.com/api-reference/customer-api/#upload-image The images should be uploaded as JPEG data with 100% quality. For example:
// with front side
let dataToUpload = result.frontIdImage.rawImage.jpegData(compressionQuality: 1.0) // 100% quality
// with back side
let dataToUpload = result.backIdImage.rawImage.jpegData(compressionQuality: 1.0) // 100% quality
if result.frontIdQr.isRequired
is true then result.frontIdQr.images
array should be non-empty. Otherwise, clients should be warned to re-capture id card photos.
QR imagegs will be uploaded with this api: https://ekyc.trustingsocial.com/api-reference/customer-api/#upload-image
result.frontIdQr.images[i].raw_image_base64
result.frontIdQr.images[i].label
result.frontIdQr.images[i].metadata
*The same logic will be applied to result.backIdQr
The selfie capturing activity will show the camera to capture image, preview the image and verify active liveness in local. To start the selfie capturing activity.
let config = TVSelfieConfiguration(
cameraOption: TVCameraOption.front,
isSoundEnable: true,
livenessMode: self.config.livenessMode,
skipConfirmScreen: false)
Options:
TVCameraOption
. Set the camera modeBool
. Sound should be played or notTVLivenessMode
. Set the liveness verification modeBool
. Skip selfie capturing confirmation screen or notlet vc = TrustVisionSdk.shared.startSelfieCapturing(configuration: config, success: { (result) in
}, failure: { (error) in
}, cancellation: {
// sdk is canceled
})
where:
TVSelfieConfiguration
TVDetectionResult
. Use the following fields:FailureCallback
CancellationCallback
// with frontal images
let dataToUpload = result.selfieImages[i].frontalImage.rawImage.jpegData(compressionQuality: 1.0) // 100% quality
// with gesture images
let dataToUpload = result.selfieImages[i].gestureImage.rawImage.jpegData(compressionQuality: 1.0) // 100% quality
id of frontal image i = image id of result.selfieImages[i].frontalImage.rawImage
id of gesture image i = image id of result.selfieImages[i].gestureImage.rawImage
Use this api to get video id:
https://ekyc.trustingsocial.com/api-reference/customer-api/#upload-videoaudioframes
id of selfie video i = video id of result.livenessVideos[i]
Call this api to check liveness https://ekyc.trustingsocial.com/api-reference/customer-api/#verify-face-liveness with params:
In images
field, each element contains:
{
"id": "<id of frontal image i>"
}
In gesture_images
field, each element contains:
{
"gesture": "lower case string of <result.selfieImages[i].gestureType.description>",
"images": [
{
"id": "<id of gesture image i>"
}
]
}
videos
field is a list which comprises 2 lists:
{
"id": "<id of selfie video i>" (step 2)
}
result.getSelfieFrameLists() // func getSelfieFrameLists() -> [[String: Any]]
With metadata
field is result.livenessMetadata
Method | Type | description |
---|---|---|
frontIdImage | TVEncryptedImage | Image of id card's front side (use field rawImage ) |
backIdImage | TVEncryptedImage | Image of id card's back side (use field rawImage ) |
frontIdQr | TVCardQr | Info of QR of id card's front side |
backIdQr | TVCardQr | Info of QR of id card's back side |
livenessResult | TVLivenessResult | Liveness check result |
selfieImages | [TVGestureImage] | Images of selfie |
livenessVideos | [Data] | List of video data during checking liveness |
getSelfieFrameLists() | [[String: Any]] | List of recorded selfie videos frames |
livenessMetadata | [String: Any]? | Collected data during liveness checking process |
Will be called in case failed. Parameters:
TVError
.Will be called in case the sdk is cancelled. No parameters