
SdkToken, which is used throughout the liveness detection and face comparison process and to pull the final verification result.
SDKToken, which is used throughout the identity verification process and used by the API [GetSdkVerificationResult](https://www.tencentcloud.com/document/product/1061/49951!f60fbe65c5f7cb4584259d37c8176b67) to obtain the verification result. The merchant server also needs to provide the corresponding endpoint for the merchant client to call. The following sample code with the Golang language is used as an example to show how to call TencentCloud API on the server and obtain the correct response.SDKToken using the ApplySdkVerificationToken API, you can return other responses required by the client application to the client along with the SDKToken.var FaceIdClient *faceid.Clientfunc init() {// Instantiate a client configuration object. You can specify the timeout period and other configuration itemsprof := profile.NewClientProfile()prof.HttpProfile.ReqTimeout = 60// TODO replace the SecretId and SecretKey string with the API SecretId and SecretKeycredential := cloud.NewCredential("SecretId", "SecretKey")var err error// Instantiate the client object of the requested faceidFaceIdClient, err = faceid.NewClient(credential, "ap-singapore", prof)if nil != err {log.Fatal("FaceIdClient init error: ", err)}}// ApplySdkVerificationToken get tokenfunc ApplySdkVerificationToken(w http.ResponseWriter, r *http.Request) {log.Println("get face id token")// Step 1: ... parse parameters_ = r.ParseForm()var IdCardType = r.FormValue("IdCardType")var NeedVerifyIdCard = false// Step 2: instantiate the request object and provide necessary parametersrequest := faceid.NewApplySdkVerificationTokenRequest()request.IdCardType = &IdCardTyperequest.NeedVerifyIdCard = &NeedVerifyIdCard// Step 3: call the Tencent Cloud API through FaceIdClientresponse, err := FaceIdClient.ApplySdkVerificationToken(request)// Step 4: process the Tencent Cloud API response and construct the return objectif nil != err {log.Println("error: ", err)_, _ = w.Write([]byte("error"))return}SdkToken := response.Response.SdkTokenapiResp := struct {SdkToken *string}{SdkToken: SdkToken}b, _ := json.Marshal(apiResp)// ... more codes are omitted//Step 5: return the service response_, _ = w.Write(b)}// GetSdkVerificationResult get resultfunc GetSdkVerificationResult(w http.ResponseWriter, r *http.Request) {// Step 1: ... parse parameters_ = r.ParseForm()SdkToken := r.FormValue("SdkToken")// Step 2: instantiate the request object and provide necessary parametersrequest := faceid.NewGetSdkVerificationResultRequest()request.SdkToken = &SdkToken// Step 3: call the Tencent Cloud API through FaceIdClientresponse, err := FaceIdClient.GetSdkVerificationResult(request)// Step 4: process the Tencent Cloud API response and construct the return objectif nil != err {_, _ = w.Write([]byte("error"))return}result := response.Response.ResultapiResp := struct {Result *string}{Result: result}b, _ := json.Marshal(apiResp)// ... more codes are omitted//Step 5: return the service response_, _ = w.Write(b)}func main() {// expose endpointshttp.HandleFunc("/api/v1/get-token", ApplySdkVerificationToken)http.HandleFunc("/api/v1/get-result", GetSdkVerificationResult)// listening porterr := http.ListenAndServe(":8080", nil)if nil != err {log.Fatal("ListenAndServe error: ", err)}
SdkToken is returned and access the API (http://ip:port/api/v1/get-result) to check whether the value of the Result field is 0. Through these results, you can determine whether the server-side integration is successful. For details on responses, see API description.// Set .so architecture filtering in NDK (using armeabi-v7a as an example)ndk {abiFilters 'armeabi-v7a'}dependencies {// Identity Verification (App SDK) versionimplementation files("libs/ekyc_android_1.0.x.x_release.aar")// Identity verification componentsimplementation files("libs/huiyansdk_android_1.0.x.x_release.aar")// OCR componentsimplementation files("libs/OcrSDK-common-model-v1.x.x-release.aar")implementation files("libs/OcrSDK-private-v2.x.x-release.aar")// Common capability componentsimplementation files("libs/tencent-ai-sdk-youtu-base-1.0.x.x-release.aar")implementation files("libs/tencent-ai-sdk-common-1.x.x-release.aar")implementation files("libs/tencent-ai-sdk-aicamera-1.x.x-release.aar")// Import a `gson` libraryimplementation 'com.google.code.gson:gson:2.8.5'}
AndroidManifest.xml file.<!-- Camera permission --><uses-permission android:name="android.permission.CAMERA" /><uses-featureandroid:name="android.hardware.camera"android:required="true" /><uses-feature android:name="android.hardware.camera.autofocus" /><!-- Permissions required by the SDK --><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><!-- Permissions optional for the SDK --><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
AndroidManifest.xml file, you need to add the code Dynamically apply for permissions.Application.@Overridepublic void onCreate() {super.onCreate();EkycHySdk.init(this);}
sdkToken required for this process, configuration information, and the callback for listening for the result.// Set startup configurationsEkycHyConfig ekycHyConfig = new EkycHyConfig();// Set the license nameekycHyConfig.setLicenseName("ekycLicense.license");ekycHyConfig.setOcrType(OcrRegionType.HK);// Customize UI configurationsOcrUiConfig config = new OcrUiConfig();ekycHyConfig.setOcrUiConfig(config);// Set specific startup verification logic// `sdkToken` is the unique credential obtained from the server for this processEkycHySdk.startEkycCheck(sdkToken, ekycHyConfig, new EkycHyCallBack() {@Overridepublic void onSuccess(EkycHyResult result) {Log.e(TAG, "result: " + result.toString());showToast ("Identity verification succeeded:" + result.toString());}@Overridepublic void onFail(int errorCode, String errorMsg, String ekycToken) {Log.e(TAG, "code: " + errorCode + " msg: " + errorMsg + " token: " + ekycToken);showToast ("Identity verification failed:" + "code: " + errorCode + " msg: " + errorMsg + " token: " + ekycToken);}});
assets folder.└── src└── main├── assets│ └── ekycLicense.license
@Overrideprotected void onDestroy() {EkycHySdk.release();super.onDestroy();}
# Objects to be obfuscated-keep class com.google.gson.** {*;}-keep class com.tencent.could.** {*;}-keep class com.tencent.youtu.** {*;}-keep class com.tencent.cloud.ocr.** {*;}-keep class com.tencent.cloud.ekyc.** {*;}
Link Binary With Libraries.├── HuiYanEKYCVerification.framework├── tnn.framework├── tnnliveness.framework├── YTCommonLiveness.framework├── YTFaceAlignmentTinyLiveness.framework├── YTFaceDetectorLiveness.framework├── YTFaceLiveReflect.framework├── YTFaceTrackerLiveness.framework├── YTPoseDetector.framework├── YtSDKKitActionLiveness.framework├── YtSDKKitFramework.framework├── YtSDKKitOcrVideoIdent.framework├── YtSDKKitReflectLiveness.framework├── YtSDKKitSilentLiveness.framework├── tiny_opencv2.framework├── HuiYanOverseasSDK.framework├── IdVerification.framework├── OcrSDKKit.framework├── TXYCommonDevice.framework├── TXYCommonNetworking.framework├── TXYCommonUtils.framework├── YTCv.framework├── YTImageRefiner.framework├── YtSDKKitFrameworkTool.framework└── YTSm.framework
Link Binary With Libraries, import the system framework.├── AVFoundation.framework├── libc++.tbd├── Accelerate.framework└── CoreML.framework
Copy Bundle Resources.├── face-tracker-v003.bundle├── huiyan_verification.bundle├── HuiYanSDKUI.bundle└── OcrSDK.bundle
Build Phases settingsOther Linker Flags, add -ObjC.ViewController.m and set the extension to .mm (for a Swift project, add the system library libc++.tbd).key-value to the project's info.plist configuration.<key>Privacy - Camera Usage Description</key><string>The SDK needs to access your camera</string>
#import <HuiYanEKYCVerification/VerificationKit.h>- (void)viewDidLoad {[[VerificationKit sharedInstance] initWithViewController:self];}
startVerifiWithConfig method with ekycToken and some other custom fields set.VerificationConfig *config = [[VerificationConfig alloc] init];config.licPath = [[NSBundle mainBundle] pathForResource:@"" ofType:nil];config.languageType = HY_EKYC_EN;config.livenessAutoTimeout = 30000;// Set the verification timeout periodconfig.ocrAutoTimeout = 20000;// Set the timeout period of a single face authentication operationconfig.ekycToken = @"";[[VerificationKit sharedInstance] startVerifiWithConfig:config withSuccCallback:^(int errorCode, id _Nonnull resultInfo, id _Nullable reserved) {NSLog(@"ErrCode:%d msg:%@",errorCode,resultInfo);} withFialCallback:^(int errorCode, NSString * _Nonnull errorMsg, id _Nullable reserved) {NSLog(@"ErrCode:%d msg:%@ extra:%@",errorCode,errorMsg,reserved);}];
Copy Bundle Resources.- (void)dealloc {[VerificationKit clearInstance];}
masukan