All Products
Search
Document Center

ID Verification:UniApp SDK

Last Updated:Nov 26, 2024

ID Verification provides a UniApp SDK that you can use to integrate electronic Know Your Customer (eKYC) capabilities into your business app. This topic describes how to integrate the UniApp SDK with a client based on sample code.

Usage notes

An individual developer that developed a third-party plug-in by encapsulating Alibaba Cloud ID Verification - KYC SDK and released the plug-in as a paid service on other platforms was discovered. Correspondingly, Alibaba Cloud made an announcement. Alibaba Cloud shall not be liable for any consequences caused by using this type of plug-in or service that is not directly provided by Alibaba Cloud and shall not assume any legal liabilities that arise from the use. We recommend that you use the SDK services provided by Alibaba Cloud.

Configure dependencies

You can integrate the UniApp SDK by following the instructions that are provided in the official documentation of DCloud. You can also perform the following steps to integrate the UniApp SDK:

  1. Download the UniApp SDK and decompress the package to the nativePlugins directory of your project.

  2. Import the extracted SDK.

  3. Create a custom debugging base.

  4. Call ID Verification (International).

    1. Obtain MetaInfo. This parameter is required when you initiate a verification request to ID Verification (International).

    2. Start verification. You must pass in transactionId when you call the verify operation. You can call the Initialize operation to obtain transactionId. The following table describes transactionId.

      Parameter

      Type

      Description

      transactionId

      String

      The unique identifier of verification.

    Sample code

    Obtain MetaInfo:

    <script>
      // Load the UniApp SDK of ID Verification (International).
      const aliyunVerify = uni.requireNativePlugin('VerifyIntlUniPlugin');
      export default {
        onLoad() {
          // Call the getMetaInfo function to obtain MetaInfo.
          var metaInfo = aliyunVerify.getMetaInfo();
          console.log(metaInfo);
        }
      }
    </script>

    Start verification:

    aliyunVerify.startVerify({
        "transactionId": "hksdecd1823a84321d7360dc5119****", // Enter the transaction ID that is obtained from ID Verification (International).
    }, function(t) {
        console.log(t)
    });
    
    // The format of the response.
    {
        code:1000,				        // The error code.
        message:"CODE_VERIFY_SUCCESS"		// The error message.
    }

Complete sample code

You can click UniApp Demo to download the sample code.

Note

The sample code is used for reference only. We recommend that you use the latest version of the UniApp SDK.

Error codes

Error code

Description

1000

The verification is successful.

The result is for reference only. You can call the CheckResult operation of ID Verification to obtain the final verification result.

1001

The verification failed.

You can call the CheckResult operation of ID Verification to query the cause of the failure.

1002

A system error occurred.

1003

The SDK failed to be initialized. Check whether the client time is valid.

1004

A camera error occurred. To fix the error, perform the following operations:

  1. Check whether your app has camera permissions before verification.

  2. If your app has camera permissions but the no-permission error persists, clear the cache of the app and try again.

1005

A network error occurred.

1006

The customer unexpectedly exited.

1007

The transaction ID is invalid.

1009

The timestamp of the client is invalid.

1011

The specified document type does not match the submitted document.

1012

The critical information is missing after document verification or the format verification failed.

1013

The image quality does not meet the requirements.

1014

The number of errors exceeds the upper limit.

1015

The Android system version is excessively early.

1016

The camera permissions are not obtained.