All Products
Search
Document Center

ID Verification:UniApp integration

Last Updated:Nov 18, 2025

ID Verification provides a plugin for the UniApp platform. You can use this plugin to add the eKYC remote identity verification feature to your UniApp application. This topic describes the UniApp integration process and provides code examples.

Before you begin

Some developers have created third-party plugins by encapsulating the Alibaba Cloud ID Verification software development kit (SDK). These plugins are sold on various platforms. Alibaba Cloud is not responsible for and assumes no legal liability for any issues that arise from using these unofficial plugins or services. To ensure stability and security, use the official Alibaba Cloud SDK.

Configure dependencies

To integrate the UniApp plugin, see the DCloud official documentation or follow these steps.

  1. Download the UniApp SDK and decompress it to the `nativePlugins` directory in your project.

  2. Import the local plugin.

    1. In the manifest.json file, click App Native Plugin Configuration.

    2. In the App Native Plugin Configuration section, click Select Local Plugin.

    3. In the Select Local Plugin dialog box, select the plugin to package.

  3. Create a custom debug base.

    1. To create a custom debug base, choose Run > Run To Phone Or Emulator > Create Custom Debug Base in the manifest.json file.

    2. To set a custom debug base, in the manifest.json file, choose Run > Run To Phone Or Emulator > Create Custom Debug Base > Run To Android/iOS App Base.

      Note

      To package the release version, choose Publish > Native App - Cloud Packaging.

Call the service

  1. Call the initWithOptions method to initialize the SDK. This method accepts the options parameter as a JSON object.

    options: Specifies optional parameters for information collection. This parameter is optional. The optional parameters are as follows:

    Note
    • The ID Verification client has a built-in Device Guard security module. To meet data collection compliance requirements in different regions, it provides different data reporting sites. You can set CustomUrl and CustomHost to specify a reporting site based on user attributes.

      Note: You can specify only one reporting site within a single application session lifecycle. The server query region must match the reporting site.

    • Specify a reporting site:

      • Singapore site (default): https://cloudauth-device.ap-southeast-1.aliyuncs.com

      • Indonesia site: https://cloudauth-device.ap-southeast-5.aliyuncs.com

      • US West (Silicon Valley): https://cloudauth-device.us-west-1.aliyuncs.com

      • Germany (Frankfurt): https://cloudauth-device.eu-central-1.aliyuncs.com

      • China (Hong Kong): https://cloudauth-device.cn-hongkong.aliyuncs.com

    • For more information about the regions supported by product servers, see Supported regions.

    Field name

    Description

    Example

    IPv6

    Specifies whether to use an IPv6 domain name to report device information:

    • 0 (default): No (use an IPv4 domain name)

    • 1: Yes (use an IPv6 domain name)

    "1"

    DataSwitch

    The timing for reporting device information.

    • 0 (default): At initialization

    • 1: When getting the token

    Note

    We recommend using the default configurations.

    "1"

    CustomUrl

    Sets the data reporting server domain name.

    "https://cloudauth-device.ap-southeast-1.aliyuncs.com"

    CustomHost

    Sets the data reporting server host.

    "cloudauth-device.ap-southeast-1.aliyuncs.com

  2. Call the `getMetaInfo` function to retrieve the MetaInfo data. Pass this value when you call the ID Verification server to start a verification request.

  3. To start the verification, call the `startVerify` function and pass the transactionId. You can obtain the transactionId by calling the server-side Initialize API.

  4. Call the startVerify() interface to initiate a verification request.

    The `startVerify()` interface has the following parameters:

    • transactionId: A required parameter.

    • extParams: Optional extension parameters.

      For information about how to configure the extension parameters (extParams), see the documentation for the native Android and iOS SDKs.

      Android

      Key

      Description

      Example (String)

      IdentityParams.OcrResultButtonColor

      The color of the button at the bottom of the OCR result page.

      #FF0000

      IdentityParams.RoundProgressColor

      The color of the circle during the face scan.

      #FF0000

      IdentityParams.ShowAlbumIcon

      In the certificate OCR step, specifies whether to show the album upload entry.

      • 1 (default): Show

      • 0: Do not show

      1

      IdentityParams.ShowOcrResult

      In the certificate OCR step, specifies whether to show the result page.

      • 1 (default): Show

      • 0: Do not show

      1

      IdentityParams.EditOcrResult

      In the certificate OCR step, specifies whether the result page is editable.

      • 1 (default): Editable

      • 0: Not editable

      1

      IdentityParams.MaxErrorTimes

      The maximum number of retries.

      The range is 3 to 10. The default is 10.

      10

      IdentityParams.CardOcrTimeOutPeriod

      The timeout period for the OCR step.

      The range is 20 to 60 seconds. The default is 20 seconds.

      20

      IdentityParams.FaceVerifyTimeOutPeriod

      The timeout period for the liveness collection and detection step.

      The range is 20 to 60 seconds. The default is 20 seconds.

      20

      IdentityParams.OcrResultTimeOutPeriod

      The duration for which the OCR result page is editable.

      You can customize this value. By default, there is no limit.

      60

      IdentityParams.SdkLanguage

      You can customize the SDK language settings. By default, the SDK uses the mobile device's system language.

      Note

      For a list of languages supported by the SDK, see Custom languages for Android and iOS SDKs.

      zh-Hans

      IdentityParams.CloseButtonLayout

      The layout of the Close button.

      • left (default): Left side

      • right: Right side

      left

      IdentityParams.WaterMark

      The watermark text after a successful OCR scan.

      Test watermark text

      IdentityParams.Protocol

      SDK Protocol.

      Note

      Get the `protocol` from the server-side Initialize API and pass it in the extension parameters. This can reduce internal API interactions in the SDK and improve the network experience.

      None

      iOS

      Key

      Description

      Example (String)

      kIdentityParamKeyNextButtonColor

      The color of the button at the bottom of the Optical Character Recognition (OCR) result page.

      #FF0000

      kIdentityParamKeyRoundProgressColor

      The color of the circle during the face scan.

      #FF0000

      kIdentityParamKeyOcrSelectPhoto

      Specifies whether to show the album upload entry during the certificate OCR step:

      • 1: Show (default)

      • 0: Hide

      1

      kIdentityParamKeyShowOcrResult

      Specifies whether to show the result page during the certificate OCR step:

      • 1: Show (default)

      • 0: Hide

      1

      kIdentutyParamKeyEditOcrResult

      Specifies whether the result page is editable during the certificate OCR step:

      • 0: Not editable

      • 1 (default): Editable

      1

      kIdentityParamKeyMaxRetryCount

      The maximum number of retries. You can set this to a value from 3 to 10. The default value is 10.

      10

      kIdentityParamKeyCardOcrTimeOutPeriod

      The timeout period for the OCR step. You can set this to a value from 20 to 60 seconds. The default value is 20 seconds.

      20

      kIdentityParamKeyFaceVerifyTimeOutPeriod

      The timeout period for the liveness collection and detection step. You can set this to a value from 20 to 60 seconds. The default value is 20 seconds.

      20

      kIdentityParamKeyCardOcrEditTimeOutPeriod

      The duration for which the OCR result page is editable. You can set this to a value from 60 to 180 seconds. By default, there is no limit.

      180

      kIdentityParamKeyLanguage

      Custom language settings for the SDK. By default, the SDK uses the language of the mobile device's operating system.

      Note

      For a list of languages supported by the SDK, see Custom languages for Android and iOS SDKs.

      zh-Hans

      kIdentityParamKeyDefaultLanguage

      The default language of the SDK. For valid values, see the kIdentityParamKeyLanguage field.

      The default value is en, which indicates English.

      en

      kIdentityParamKeyCloseButtonPosition

      The position of the SDK's Close button:

      • left: Left (default)

      • right: Right

      left

      kIdentityParamKeyWatermark

      The watermark text after successful OCR.

      Test watermark text

      kIdentutyParamKeyProtocol

      The SDK protocol.

      Note

      Obtain the protocol from the server-side Initialize API and pass it in the extension parameters. This can reduce internal SDK API interactions and improve the network experience.

      968412EB*******...

      The following example shows how to pass parameters:

      // For Android,
      aliyunVerify.startVerify({
        transactionId:"<verification_id>",// Enter the transactionId obtained from the server.
        SdkLanguage:"cn"// Pass the fields in the extension parameters.	
      }, function(t){
        console.log(t)
      });
      
      // Response format
      {
        code:1000,				 // Error code
        message:"CODE_VERIFY_SUCCESS"		// Error code description
      }
  5. Call the setCustomUI() interface to customize UI colors.

    params: Pass the data in JSON format. For more information about UI customization configurations, see the documentation for the native SDKs:

Complete code example

<template>
  <view class="button-sp-area">
  <button type="primary" plain="true" @click="init">init</button>
  <button type="primary" plain="true" @click="getMetaInfo">getMetaInfo</button>
  <button type="primary" plain="true" @click="verify">verify</button>
  <button type="primary" plain="true" @click="setCustomUi">setCustomUi</button>
		
  </view>
</template>

<script>
const aliyunVerify = uni.requireNativePlugin('VerifyIntlUniPlugin');
	
export default {
  data() {
    return {
      title: ''
    }
  },
  onLoad() {
			
  },
  methods: {
    init:function() {
      console.log("init");
      const json={
        CustomUrl:"https://cloudauth-device.ap-southeast-5.aliyuncs.com",
        CustomHost:"cloudauth-device.ap-southeast-5.aliyuncs.com"
      };
      aliyunVerify.initWithOptions(json);
    },
    getMetaInfo:function() {
      console.log("getMetaInfo");
      var t = aliyunVerify.getMetaInfo();
      console.log(t);
      uni.showToast({
        title: t,
        icon: 'none'
      });
    },
    setCustomUi:function(){
      const json={
        faceConfig:{faceBGColor:"#FF00FF"}
      };
      var t = aliyunVerify.setCustomUI(JSON.stringify(json));
      console.log("setCustomUi"+t);
    },
    verify:function(){
      console.log("Face Verify");
      aliyunVerify.startVerify({
          transactionId:"xxxxx",// Verification ID
        }, 
       function(t){
         console.log(t);
         const msg = JSON.stringify(t);
         console.log(msg);
         // uni.showToast({
         // 	title: t,
         // 	icon: 'none'
         // });
       });
    }
  }
}
</script>
<style>
button {
  margin-top: 30upx;
  margin-bottom: 30upx;
}

.button-sp-area {
  margin: 0 auto;
  width: 60%;
}

.content {
  text-align: center;
  height: 400upx;
}

.wrapper {
  flex-direction: column;
  justify-content: center;
}

.button {
  width: 200px;
  margin-top: 30px;
  margin-left: 20px;
  padding-top: 20px;
  padding-bottom: 20px;
  border-width: 2px;
  border-style: solid;
  border-color: #458B00;
  background-color: #458B00;
}

.text {
  font-size: 30px;
  color: #666666;
  text-align: center;
}
</style>

You can also download the UniApp Demo to view a complete example.

Important

This demo code is provided for integration reference only. Ensure that you use the latest SDK version for your application.

Error codes

Error code

Description

1000

Verification successful.

This result is for reference only. Call the server-side CheckResult API to get the final verification result.

1001

Verification failed.

To get detailed failure reasons, call the server-side CheckResult API.

1002

System error.

1003

SDK initialization failed. Check if the client time is correct.

1004

Camera permission error. Try the following steps to resolve the issue:

  1. Before verification, make sure the app has camera permission.

  2. If the permission error persists after you grant the permission, clear the app cache and retry.

1005

Network error.

1006

User exited.

1007

Invalid TransactionId.

1009

Client timestamp error.

1011

Incorrect certificate type submitted.

1012

Key information from the detected certificate is missing or the format check failed.

1013

Poor image quality.

1014

The number of errors exceeded the upper limit.

1015

The Android system version is too low.

1016

Camera permission not granted.