All APIs were called from the Bank's backend. No API calls at SDK.
Reference Scenario
flow_id
to use for your business: eg. retail
or enterprise
Use API directly: Get client settings
Use Java SDK: Java API librarary
// Get client settings
String flowID = "retail"
TVResponseData<TVClientSettings> response = TVApi.getInstance().getClientSettings(flowID);
if (response.hasErrors()) {
List<TVApiError> errors = response.getErrors();
System.out.println("Get client settings error:" + errors.get(0).getMessage());
} else {
System.out.println("Get client settings successful");
}
System.out.println(response.getRawJSON());
Pass the settings string from step 1 to parameter jsonConfigurationByServer
Android: Init SDK
iOS: Init SDK
React Native: Init SDK
Flutter: Init SDK
val config = TVInitializeConfiguration(
jsonConfigurationByServer = jsonConfigurationByServer,
languageCode = languageCode,
theme = theme
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
TrustVisionSDK.init(context, config, object : TVInitializeListener {
override fun onInitSuccess(result: TVInitResult) {
// Start capture ID card or capture selfie
// eg. TrustVisionSDK.startIDCapturing(...)
// or TrustVisionSDK.startSelfieCapturing(...)
}
override fun onInitError(error: TVDetectionError) {
// Handle errors
}
})
}
Android: Start capture ID Card
iOS: Start capture ID Card
React Native: Start capture ID Card
Flutter: Start capture ID Card
param | Android | iOS |
---|---|---|
cardTypes | Reference | Reference |
cardSide | cardSide = TVSDKConfiguration.TVCardSide.FRONT | cardSide: TVIdCardConfiguration.TVCardSide.front |
val configuration = TVIDConfiguration(
enableSound = true,
cardTypes = selectedCards,
cardSide = TVSDKConfiguration.TVCardSide.FRONT,
isReadBothSide = false,
isEnableScanNfc = true,
isEnableScanQr = true,
isEnablePhotoGalleryPicker = false,
isEnableTiltChecking = false,
isSkipConfirmScreen = true,
isEnableUploadFrames = false,
isEnableUploadImages = false,
isEnableSanityCheck = false,
isEnableDetectIdCardTampering = false,
isEnableReadCardInfo = false,
isEnableCheckNfcData = false,
isEnableVerifyNfc = false
)
TrustVisionSDK.startIDCapturing(activity, configuration, object : TVCapturingCallBack() {
override fun onNewFrameBatch(frameBatch: FrameBatch) {
}
override fun onError(error: TVDetectionError) {
}
override fun onSuccess(result: TVDetectionResult) {
}
override fun onCanceled(reason: TVCancelReason) {
}
override fun readIdCardImage(image: TVImageClass): TVNfcParams? {
}
})
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
var frontCardId: String? = null
var backCardId: String? = null
var frontQrId: String? = null
var backQrId: String? = null
fun onSuccess(result: TVDetectionResult) {
// With front side
frontCardId = result.frontCardImage?.imageByteArray?.let {
yourMethodToUploadImage(it)
}
// With back side
backCardId = result.backCardImage?.imageByteArray?.let {
yourMethodToUploadImage(it)
}
// In case the QR capturing feature is enabled, and `result.getCardQrImage()` is null then
// the user will be notified, so they can choose to re-capture their ID card.
frontQrId = result.frontIdQr?.images?.getOrNull(i)?.imageByteArray?.let {
yourMethodToUploadImage(it)
}
backQrId = result.backIdQr?.images?.getOrNull(i)?.imageByteArray?.let {
yourMethodToUploadImage(it)
}
}
After you have image id from upload, you can call API ID card sanity, ID Card tampering and OCR
Check ID Card sanity:
Use Java SDK
Use API directly
Check ID Card tampering:
Use Java SDK
Use API directly
Read ID Card info (OCR):
Use Java SDK
Use API directly
Android: Start capture the Selfie
iOS: Start capture the Selfie
React Native: Start capture the Selfie
Flutter: Start capture the Selfie
param | Android | iOS |
---|---|---|
livenessMode | livenessMode = TVLivenessMode.FLASH_16 | livenessMode: TVLivenessMode.flash_16 |
val configuration = TVSelfieConfiguration(
cameraOption = TVCameraOption.FRONT,
enableSound = true,
livenessMode = TVLivenessMode.FLASH_16,
isEnableVerticalChecking = true,
isSkipConfirmScreen = true,
isEnableUploadFrames = false,
isEnableUploadImages = false,
isEnableSanityCheck = false,
isEnableVerifyLiveness = false
)
TrustVisionSDK.startSelfieCapturing(activity, configuration, object : TVCapturingCallBack() {
override fun onNewFrameBatch(frameBatch: FrameBatch) {
}
override fun onError(error: TVDetectionError) {
}
override fun onSuccess(result: TVDetectionResult) {
}
override fun onCanceled(reason: TVCancelReason) {
}
})
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
Android: Handle results from SDK iOS: Handle results from SDK
Note: frames video were batched and sent to host app via method onNewFrameBatch
to upload async.
onNewFrameBatch
// this dictionary will be used for face liveness Verification
val selfieFrameBatchIdsDictionary: MutableMap<String, String> = mutableMapOf()
// frameBatchIdsDictionary.put(
// key = <id_returned_from_sdk>,
// value = <id_responded_from_server>
// )
override fun onNewFrameBatch(frameBatch: FrameBatch) {
val gson = Gson()
val framesStr = gson.toJson(frameBatch.frames)
val params: MutableMap<String, Any> = HashMap()
params["frames"] = framesStr
params["metadata"] = frameBatch.metadata
params["label"] = "video"
val jsonToBeUploaded = gson.toJson(params)
// upload frame batch to server using this api:
// https://ekyc.trustingsocial.com/api-reference/customer-api/#upload-videoaudioframes
val uploadingResult: YourResponseObject = yourMethodToUploadFrameBatch(jsonToBeUploaded)
// Keep the id that generated by the SDK corresponding with the one responded from server
selfieFrameBatchIdsDictionary[frameBatch.id] = uploadingResult.fileId
}
// These lists of image ids will be used in Liveness Verification
val frontalImageIds = mutableListOf<String>()
val gestureImageIds = mutableListOf<String>()
override fun onSuccess(result: TVDetectionResult) {
handleSelfieImages(result.faces, result.gestureFaces)
}
private fun handleSelfieImages(faces: List<TVImageClass>?, gestureFaces: List<TVGestureFace>?) {
faces?.forEach { face ->
// Handle frontal images
face.imageByteArray?.also {
// frontalImageId is the id of the image, returned from server when the uploading API is completed successfully
val frontalImageId = yourUploadImageMethod(it)
frontalImageIds.add(frontalImageId)
}
}
gestureFaces?.forEach { face ->
// Handle gesture images
face.images.forEach { image ->
// gestureImageId is the id of the image, returned from server when the uploading API is completed successfully
val gestureImageId = yourUploadImageMethod(image.imageByteArray ?: return@forEach)
gestureImageIds.add(gestureImageId)
}
}
}
After you have image id, video id from upload, you can call API Portrait sanity, Liveness check and Compare face with image_id of ID card frontside from step 5. Note: Use last frontal image_id to call API Portrait sanity, Compare face with image_id of ID Card, Search face and Index face.
Check Portrait sanity:
Use Java SDK
Use API directly
Check Liveness:
Use Java SDK
Use API directly
Compare Faces:
Use Java SDK
Use API directly
Search Faces:
Use Java SDK
Use API directly
Index Faces:
Use Java SDK
Use API directly
There are some APIs called from SDK. There are some APIs called from the client's backend.
Reference Scenario
Use API directly: Create temporary credential
Use Java SDK: Create temporary credentials
// Create temporary credentials
int durationInSeconds = 900;
String transactionID = "";
String xRequestID = "";
String xRequestID2 = "";
Map<String, String> headers = new HashMap<String, String>();
headers.put("X-Request-Id", xRequestID);
headers.put("X-Request-Id2", xRequestID2);
TVTemporaryCredentialRequest request = new TVTemporaryCredentialRequest(durationInSeconds);
TVResponseData<TVTemporaryCredentialResponse> response = TVApi.getInstance().createTemporaryCredential(request, transactionID, headers);
System.out.println("TVTemporaryCredentialResponse: " + GsonUtils.toJson(response));
if (response.hasErrors()) {
List<TVApiError> errors = response.getErrors();
System.out.println("Create temporary credentials error:" + errors.get(0).getMessage());
} else {
System.out.println("Create temporary credentials successful");
}
Use Java SDK: Reference
props | description |
---|---|
x-request-id | API reconciliation. Reference |
x-request-id2 | Hash(x-request-id2) . Reference |
access_key | the value from API temporary credentials. Reference |
secret_key | the value from API temporary credentials. Reference |
face_auth_endpoint | the value from TS's administrator |
Android: Init SDK
iOS: Init SDK
React Native: Init SDK
Flutter: Init SDK
flowId
parameter is defined for each use-case differentlyflowId | description |
---|---|
retail | Onboarding for retail customer |
enterprise | Onboarding for enterprise customer |
... | You can define any authentication type based on your business |
parameter | description |
---|---|
endpoint | From step 1. Please contact administrator to get correct endpoint |
accessKeyId | From step 1 |
accessKeySecret | From step 1 |
xRequestId | From step 1 |
xRequestId2 | From step 1 |
Which endpoint
depend on each environment of country:
Testing:
val config = TVInitializeConfiguration(
endpoint = endpoint,
accessKeyId = accessKeyId,
accessKeySecret = accessKeySecret,
xRequestId = xRequestId,
xRequestId2 = xRequestId2_of_backend at step1,
flowId = flowId,
languageCode = languageCode,
theme = theme
)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
TrustVisionSDK.init(context, config, object : TVInitializeListener {
override fun onInitSuccess(result: TVInitResult) {
// Start capture ID card or capture selfie
// eg. TrustVisionSDK.startIDCapturing(...)
// or TrustVisionSDK.startSelfieCapturing(...)
}
override fun onInitError(error: TVDetectionError) {
// Handle errors
}
})
}
Android: Start capture ID Card
iOS: Start capture ID Card
React Native: Start capture ID Card
Flutter: Start capture ID Card
param | Android | iOS |
---|---|---|
cardTypes | Reference | Reference |
cardSide | cardSide = TVSDKConfiguration.TVCardSide.FRONT | cardSide: TVIdCardConfiguration.TVCardSide.front |
isEnableUploadImages | isEnableUploadImages = true | isEnableUploadImages: true |
isEnableUploadFrames | isEnableUploadFrames = true | isEnableUploadFrames: true |
val configuration = TVIDConfiguration(
enableSound = true,
cardTypes = selectedCards,
cardSide = TVSDKConfiguration.TVCardSide.FRONT,
isReadBothSide = false,
isEnableScanNfc = true,
isEnableScanQr = true,
isEnablePhotoGalleryPicker = false,
isEnableTiltChecking = false,
isSkipConfirmScreen = true,
isEnableUploadFrames = true,
isEnableUploadImages = true,
isEnableSanityCheck = false,
isEnableDetectIdCardTampering = false,
isEnableReadCardInfo = false,
isEnableCheckNfcData = false,
isEnableVerifyNfc = false
)
TrustVisionSDK.startIDCapturing(activity, configuration, object : TVCapturingCallBack() {
override fun onNewFrameBatch(frameBatch: FrameBatch) {
}
override fun onError(error: TVDetectionError) {
}
override fun onSuccess(result: TVDetectionResult) {
}
override fun onCanceled(reason: TVCancelReason) {
}
override fun readIdCardImage(image: TVImageClass): TVNfcParams? {
}
})
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
var frontCardId: String? = null
var backCardId: String? = null
var frontQrId: String? = null
var backQrId: String? = null
fun onSuccess(result: TVDetectionResult) {
// With front side
frontCardId = result.frontCardImage?.imageID
// With back side
backCardId = result.backCardImage?.imageID
// In case the QR capturing feature is enabled, and `result.getCardQrImage()` is null then
// the user will be notified, so they can choose to re-capture their ID card.
frontQrId = result.frontIdQr?.imageID
backQrId = result.backIdQr?.imageID
}
After you have image id from upload, you can call API ID card sanity, ID Card tampering and OCR
Check ID Card sanity:
Use Java SDK
Use API directly
Check ID Card tampering:
Use Java SDK
Use API directly
Read ID Card info (OCR):
Use Java SDK
Use API directly
Android: Start Face Authentication
iOS: Start Face Authentication
React Native: Start Face Authentication
Flutter: Start Face Authentication
param | Android | iOS |
---|---|---|
livenessMode | livenessMode = TVLivenessMode.FLASH_16 | livenessMode: TVLivenessMode.flash_16 |
isEnableUploadImages | isEnableUploadImages = true | isEnableUploadImages: true |
isEnableUploadFrames | isEnableUploadFrames = true | isEnableUploadFrames: true |
val configuration = TVSelfieConfiguration(
cameraOption = TVCameraOption.FRONT,
enableSound = true,
livenessMode = TVLivenessMode.FLASH_16,
isEnableVerticalChecking = true,
isSkipConfirmScreen = true,
isEnableUploadFrames = true,
isEnableUploadImages = true,
isEnableSanityCheck = false,
isEnableVerifyLiveness = false
)
TrustVisionSDK.startSelfieCapturing(activity, configuration, object : TVCapturingCallBack() {
override fun onNewFrameBatch(frameBatch: FrameBatch) {
}
override fun onError(error: TVDetectionError) {
}
override fun onSuccess(result: TVDetectionResult) {
}
override fun onCanceled(reason: TVCancelReason) {
}
})
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
Android: Handle results from SDK iOS: Handle results from SDK
Note: frames video were batched and sent to host app via method onNewFrameBatch
to upload async.
// These lists of image ids will be used in Liveness Verification
val frontalImageIds = mutableListOf<String>()
val gestureImageIds = mutableListOf<String>()
override fun onSuccess(result: TVDetectionResult) {
val faceIds: List<TVImageClass> = result.faces?.map {
TVSyncFile.createById(it.imageId)
} ?: emptyList()
val gestureFaces: List<TVGestureFace> = result.gestureFaces?.map {
val gesture = it.gesture
val ids = it.images.map { img -> TVSyncFile.createById(img.imageId) }
TVGestureImage(gesture, ids)
} ?: emptyList()
val videoIds = result.livenessFrameBatchIds?.map {
TVVideoFile.createById(it)
}
}
After you have image id, video id from upload, you can call API Portrait sanity, Liveness check and Compare face with image_id of ID card frontside from step 5. Note: Use last frontal image_id to call API Portrait sanity, Compare face with image_id of ID Card, Search face and Index face.
Check Portrait sanity:
Use Java SDK
Use API directly
Check Liveness:
Use Java SDK
Use API directly
Compare Faces:
Use Java SDK
Use API directly
Search Faces:
Use Java SDK
Use API directly
Index Faces:
Use Java SDK
Use API directly