User Onboarding
I.1 Recommended: UI Only. Client fully control
All APIs were called from the Bank's backend. No API calls at SDK.
Reference Scenario

Step 1: Get settings from Backend
- Define
flow_idto use for your business: eg.retailorenterprise
Use API directly: Get client settings
Use Java SDK: Java API library
Sample code
// 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());
Step 2: Init SDK with settings from Step 1
Pass the settings string from step 1 to parameter jsonConfigurationByServer
Android: Init SDK
iOS: Init SDK
React Native: Init SDK
Flutter: Init SDK
Sample code
TVInitializeConfiguration config = new TVInitializeConfiguration.Build()
.setJsonConfigurationByServer(jsonConfigurationByServer)
.setLanguageCode(languageCode)
.setTheme(theme)
.build();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TrustVisionSDK.INSTANCE.init(context, config, new BaseTrustVisionSDK.TVInitializeListener() {
@Override
public void onInitSuccess() {
// Start capture ID card or capture selfie
// eg. TrustVisionSDK.startIDCapturing(...)
// or TrustVisionSDK.startSelfieCapturing(...)
}
@Override
public void onInitError(@NonNull TVDetectionError error) {
// Handle errors
}
});
}
Step 3: Start capture the frontside of ID Card after init SDK successfully.
Android: Start capture ID Card
iOS: Start capture ID Card
React Native: Start capture ID Card
Flutter: Start capture ID Card
Parameters:
| param | Android | iOS |
|---|---|---|
cardTypes | Reference | Reference |
cardSide | cardSide = TVSDKConfiguration.TVCardSide.FRONT | cardSide: TVIdCardConfiguration.TVCardSide.front |
Sample code
TVIDConfiguration.Builder builder= new TVIDConfiguration.Builder()
.setEnableSound(true)
.setCardType(selectedCard)
.setCardSide(TVSDKConfiguration.TVCardSide.FRONT)
.setReadBothSide(false)
.setEnableScanNfc(true)
.setEnableScanQr(true)
.setEnablePhotoGalleryPicker(false)
.setEnableTiltChecking(false)
.setSkipConfirmScreen(true)
.setEnableUploadFrames(false)
.setEnableUploadImages(false)
.setEnableSanityCheck(false)
.setEnableDetectIdCardTampering(false)
.setEnableReadCardInfo(false)
.setEnableCheckNfcData(false)
.setEnableVerifyNfc(false);
TVIDConfiguration configuration=builder.build();
TrustVisionSDK.INSTANCE.startIDCapturing(activity, configuration, new TVCapturingCallBack(){
@Override
public void onNewFrameBatch(FrameBatch frameBatch){
}
@Override
public void onError(TVDetectionError error){
}
@Override
public void onSuccess(TVDetectionResult result){
}
@Override
public void onCanceled(TVCancelReason reason){
}
@Override
public TVNfcParams readIdCardImage(@NonNull TVImageClass image) {
}
});
Step 4: Mobile App receives result images from SDK
Images: The result was returned after the SDK finish.
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
- SDK output result images.
- Mobile App upload images to server.
- To upload image use API Upload image
- After upload all images finish go to step 5.
Sample code
String frontCardId;
String backCardId;
String frontQrId;
String backQrId;
@Override
public void onSuccess(TVDetectionResult result) {
// With front side
if (result.getFrontCardImage() && result.getFrontCardImage().getImageByteArray() != null){
byte[] frontImageData = result.getFrontCardImage().getImageByteArray();
frontCardId = yourMethodToUploadImage(frontImageData);
}
// With back side
if (result.getBackCardImage() && result.getBackCardImage().getImageByteArray() != null) {
byte[] backImageData = result.getBackCardImage().getImageByteArray();
backCardId = yourMethodToUploadImage(backImageData);
}
// 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.
if (result.getFrontIdQr() != null && !result.getFrontIdQr().getImages().isEmpty()) {
byte[] qrImageData = result.getFrontIdQr().getImages().get(i).getImageByteArray();
frontQrId = yourMethodToUploadImage(qrImageData);
}
if (result.getBackIdQr() != null && !result.getBackIdQr().getImages().isEmpty()) {
byte[] qrImageData = result.getBackIdQr().getImages().get(i).getImageByteArray();
frontQrId = yourMethodToUploadImage(qrImageData);
}
}
Step 5: Integrate client's backend call TS's backend
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 directlyCheck ID Card tampering:
Use Java SDK
Use API directlyRead ID Card info (OCR):
Use Java SDK
Use API directly
Step 6: Repeat from step 3 to step 5 for backside of ID card.
Step 7: Start capture the Selfie
Android: Start capture the Selfie
iOS: Start capture the Selfie
React Native: Start capture the Selfie
Flutter: Start capture the Selfie
Parameters:
| param | Android | iOS |
|---|---|---|
livenessMode | livenessMode = TVLivenessMode.FLASH_16 | livenessMode: TVLivenessMode.flash_16 |
Sample code
TVSelfieConfiguration configuration = new TVSelfieConfiguration.Builder()
.setCameraOption(TVSDKConfiguration.TVCameraOption.FRONT)
.setEnableSound(false)
.setLivenessMode(TVLivenessMode.PASSIVE)
.setEnableVerticalChecking(false)
.setSkipConfirmScreen(false)
.setEnableUploadFrames(false)
.setEnableUploadImages(false)
.setEnableSanityCheck(false)
.setEnableVerifyLiveness(false)
.build();
TrustVisionSDK.INSTANCE.startSelfieCapturing(activity, configuration, new TVCapturingCallBack() {
@Override
public void onNewFrameBatch(FrameBatch frameBatch) {
}
@Override
public void onError(TVDetectionError error) {
}
@Override
public void onSuccess(TVDetectionResult result) {
}
@Override
public void onCanceled(TVCancelReason reason){
}
});
Step 8: Mobile App receives result images, frames videos from SDK
Images: The result was returned after the SDK finish.
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
Video frames: The result will return each batch while user perform action in realtime.
Android: Handle results from SDK iOS: Handle results from SDK
- SDK output result images, and frames videos.
- Mobile App upload images and frames videos to server.
- To upload image use API Upload image
- To upload frames video use API Upload frames
- After upload all images, frames videos finish go to step 9.
Note: frames video were batched and sent to host app via method onNewFrameBatch to upload async.
Sample code: Receive video frames via callback onNewFrameBatch
// this dictionary will be used for Liveness verification
Map selfieFrameBatchIdsDictionary = new HashMap<String, String>();
// frameBatchIdsDictionary.put(
// key = <id_returned_from_sdk>,
// value = <id_responded_from_server>
// );
@Override
public void onNewFrameBatch(FrameBatch frameBatch) {
Gson gson = new Gson();
String framesStr = gson.toJson(frameBatch.getFrames());
Map<String, Object> params = new HashMap<>();
params.put("frames", framesStr);
params.put("metadata", frameBatch.getMetadata());
params.put("label", "video");
String jsonToBeUploaded = gson.toJson(map);
// upload frame batch to server using this api:
// /ekyc-core/image-file/upload-video-audio-frames/
YourResponseObject uploadingResult = yourMethodToUploadFrameBatch(jsonToBeUploaded);
// Keep the id that generated by the SDK corresponding with the one responded from server
selfieFrameBatchIdsDictionary.put(
key = frameBatch.getId(),
value = uploadingResult.fileId
);
}
Sample code: Receive images after SDK finish.
// These lists of image ids will be used in Liveness Verification
List<String> frontalImageIds = new ArrayList<>();
List<String> gestureImageIds = new ArrayList<>();
@Override
public void onSuccess(TVDetectionResult result) {
handleSelfieImages(result.getFaces(), result.getGestureFaces());
}
private void handleSelfieImages(List<TVImageClass> faces, List<TVGestureFace> gestureFaces) {
for (face: faces) {
// Handle frontal images
if (face.getImageByteArray() != null){
byte[] frontalImageByteArray = face.getImageByteArray();
// frontalImageId is the id of the image, returned from server when the uploading API is completed successfully
String frontalImageId = yourUploadImageMethod(frontalImageByteArray);
frontalImageIds.add(frontalImageId);
}
}
for (face: gestureFaces) {
for (image: face.getImages) {
// Handle gesture images
if (image.getImageByteArray() != null){
byte[] gestureImageByteArray = image.getImageByteArray();
// gestureImageId is the id of the image, returned from server when the uploading API is completed successfully
String gestureImageId = yourUploadImageMethod(gestureImageByteArray);
gestureImageIds.add(gestureImageId);
}
}
}
}
Step 9: Integrate client's backend call TS's backend
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 directlyCheck Liveness:
Use Java SDK
Use API directlyCompare Faces:
Use Java SDK
Use API directlySearch Faces:
Use Java SDK
Use API directlyIndex Faces:
Use Java SDK
Use API directly
I.2 Hybrid: Share APIs called for both SDK and client's backend.
There are some APIs called from SDK. There are some APIs called from the client's backend.
Reference Scenario

Step 1: Create temporary credentials with a verified session token.
Use API directly: Create temporary credential
Use Java SDK: Create temporary credentials
Sample code
// 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");
}
Secure X-Request-ID2 to return SDK
Use Java SDK: Reference
Return Mobile values to init SDK
| 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 |
Step 2: Init SDK with temporary credential from Step 1
Android: Init SDK
iOS: Init SDK
React Native: Init SDK
Flutter: Init SDK
Parameters:
The flowId parameter is defined for each use-case differently
| flowId | description |
|---|---|
retail | Onboarding for retail customer |
enterprise | Onboarding for enterprise customer |
... | You can define any authentication type based on your business |
Other parameters:
| 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:
- Vietnam: https://vn-staging.trustingsocial.com/api
- Philippines: https://ph-vision-staging.trustingsocial.com/api Production: Please contact administrator.
Sample code
TVInitializeConfiguration config = new TVInitializeConfiguration.Build()
.setEndpoint(endpoint)
.setAccessKeyId(accessKeyId)
.setAccessKeySecret(accessKeySecret)
.setXRequestId(xRequestId)
.setXRequestId2(xRequestId2)
.setFlowId(flowId)
.setLanguageCode(languageCode)
.setTheme(theme)
.build();
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TrustVisionSDK.INSTANCE.init(context, config, new BaseTrustVisionSDK.TVInitializeListener() {
@Override
public void onInitSuccess() {
// Start capture ID card or capture selfie
// eg. TrustVisionSDK.startIDCapturing(...)
// or TrustVisionSDK.startSelfieCapturing(...)
}
@Override
public void onInitError(@NonNull TVDetectionError error) {
// Handle errors
}
});
}
Step 3: Start capture the frontside of ID Card after init SDK successfully.
Android: Start capture ID Card
iOS: Start capture ID Card
React Native: Start capture ID Card
Flutter: Start capture ID Card
Parameters:
| 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 |
Sample code
TVIDConfiguration.Builder builder= new TVIDConfiguration.Builder()
.setEnableSound(true)
.setCardType(selectedCard)
.setCardSide(TVSDKConfiguration.TVCardSide.FRONT)
.setReadBothSide(false)
.setEnableScanNfc(true)
.setEnableScanQr(true)
.setEnablePhotoGalleryPicker(false)
.setEnableTiltChecking(false)
.setSkipConfirmScreen(true)
.setEnableUploadFrames(true)
.setEnableUploadImages(true)
.setEnableSanityCheck(false)
.setEnableDetectIdCardTampering(false)
.setEnableReadCardInfo(false)
.setEnableCheckNfcData(false)
.setEnableVerifyNfc(false);
TVIDConfiguration configuration=builder.build();
TrustVisionSDK.INSTANCE.startIDCapturing(activity, configuration, new TVCapturingCallBack(){
@Override
public void onNewFrameBatch(FrameBatch frameBatch){
}
@Override
public void onError(TVDetectionError error){
}
@Override
public void onSuccess(TVDetectionResult result){
}
@Override
public void onCanceled(TVCancelReason reason){
}
@Override
public TVNfcParams readIdCardImage(@NonNull TVImageClass image) {
}
});
Step 4: Mobile App receives result image IDs from SDK
Images: The result was returned after the SDK finish.
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
- SDK output result image ID and go to step 5.
Sample code
String frontCardId;
String backCardId;
String frontQrId;
String backQrId;
@Override
public void onSuccess(TVDetectionResult result) {
// With front side
frontCardId = result.getFrontCardImage().getImageId();
// With back side
backCardId = result.getBackCardImage().getImageId();
// 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.getFrontIdQr().getImageId();
backQrId = result.getBackIdQr().getImageId();
}
Step 5: Integrate client's backend call TS's backend
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 directlyCheck ID Card tampering:
Use Java SDK
Use API directlyRead ID Card info (OCR):
Use Java SDK
Use API directly
Step 6: Repeat from step 3 to step 5 for backside of ID card.
Step 7: Start capture the Selfie
Android: Start Face Authentication
iOS: Start Face Authentication
React Native: Start Face Authentication
Flutter: Start Face Authentication
Parameters:
| param | Android | iOS |
|---|---|---|
livenessMode | livenessMode = TVLivenessMode.FLASH_16 | livenessMode: TVLivenessMode.flash_16 |
isEnableUploadImages | isEnableUploadImages = true | isEnableUploadImages: true |
isEnableUploadFrames | isEnableUploadFrames = true | isEnableUploadFrames: true |
Sample code
TVSelfieConfiguration configuration = new TVSelfieConfiguration.Builder()
.setCameraOption(TVSDKConfiguration.TVCameraOption.FRONT)
.setEnableSound(false)
.setLivenessMode(TVLivenessMode.PASSIVE)
.setEnableVerticalChecking(false)
.setSkipConfirmScreen(false)
.setEnableUploadFrames(true)
.setEnableUploadImages(true)
.setEnableSanityCheck(false)
.setEnableVerifyLiveness(false)
.build();
TrustVisionSDK.INSTANCE.startSelfieCapturing(activity, configuration, new TVCapturingCallBack() {
@Override
public void onNewFrameBatch(FrameBatch frameBatch) {
}
@Override
public void onError(TVDetectionError error) {
}
@Override
public void onSuccess(TVDetectionResult result) {
}
@Override
public void onCanceled(TVCancelReason reason){
}
});
Step 8: Mobile App receives result image IDs, frames video IDs from SDK
Images: The result was returned after the SDK finish.
Android: Handle results from SDK
iOS: Handle results from SDK
React Native: Handle results from SDK
Flutter: Handle results from SDK
Video frames: The result will return each batch while user perform action in realtime.
Android: Handle results from SDK iOS: Handle results from SDK
- SDK output result image IDs, and frames video IDs. Go to step 9
Note: frames video were batched and sent to host app via method onNewFrameBatch to upload async.
Sample code: Receive image IDs and video IDs after SDK finish.
// These lists of image ids will be used in Liveness Verification
List<String> frontalImageIds = new ArrayList<>();
List<String> gestureImageIds = new ArrayList<>();
@Override
public void onSuccess(TVDetectionResult result) {
List<TVSyncFile> faceIds = new ArrayList();
List<TVGestureImage> gestureFaces = new ArrayList();
List<TVVideoFile> videoIds = new ArrayList();
String cusUserId = "1";
String selfieType = "selfie";
String authType = "transfer";
for (TVImageClass face: result.getFaces()) {
faceIds.add(TVSyncFile.createById(face.getImageId());
}
for (TVGestureFace gesture: result.getGestureFaces()) {
String gestureName = gesture.getGesture();
List<TVSyncFile> ids = new ArrayList();
for (TVImageClass img: gesture.getImages()) {
ids.add(TVSyncFile.createById(img.getImageId()));
}
gestureFaces.add(new TVGestureImage(gesture, ids));
}
for (String id: result.getLivenessFrameBatchIds()) {
videoIds.add(TVVideoFile.createById(id));
}
}
Step 9: Integrate client's backend call TS's backend
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 directlyCheck Liveness:
Use Java SDK
Use API directlyCompare Faces:
Use Java SDK
Use API directlySearch Faces:
Use Java SDK
Use API directlyIndex Faces:
Use Java SDK
Use API directly