# @digiotech/react-native 中文文档

规范地址：https://npmcn.com/package/%40digiotech/react-native/

版本：2\.0\.20
npm 元数据更新时间：2026-11-10T11:45:51.402Z
中文译文更新时间：2026-11-12T08:17:20.388Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40digiotech/react-native
原文对照：https://npmcn.com/package/%40digiotech/react-native/?lang=original
项目主页：https://github.com/digio-tech/reactnative-sdk#readme
源码仓库：https://github.com/digio-tech/reactnative-sdk

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：88.5 kB，74 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>= 18\.0\.0
- 运行依赖：0 个
- peer 依赖：react \*，react-native \*
- 首次发布：2023-10-27T07:14:40.762Z
- 最新版本发布：2026-11-10T11:45:51.203Z
- 近 30 天下载量：6231（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：50（近 12 个月 23 个）

## 中文简介

Digio React Independent SDK用于引用客户端的行程,如KYC,Selfie,Authority,RPD等Digio工作流程.

## 安装

```sh
npm install @digiotech/react-native
```

也可以使用：`pnpm add @digiotech/react-native`、`yarn add @digiotech/react-native`、`bun add @digiotech/react-native`

## README

# Digio 反应原生 SDK

[![npm version](https://badge.fury.io/js/@digiotech%2Freact-native.svg)](https://badge.fury.io/js/@digiotech%2Freact-native) [![Release Notes](https://img.shields.io/github/v/release/digio-tech/reactnative-sdk?label=Release%20Notes&color=blue)](https://github.com/digio-tech/reactnative-sdk/releases)

Digio Gateway 整合的官方反应原生 SDK

## 安装

```sh
yarn install @digiotech/react-native
```

## 文档

Digio网关集成的文件及其使用

### 基本用途

证明Digio案 `environment` 其他选项( o)

```tsx
import { Digio, DigioConfig, DigioResponse, ServiceMode } from '@digiotech/react-native';

const config: DigioConfig = { environment: Environment.PRODUCTION, serviceMode: ServiceMode.OTP, isGlobal: false  };
const digio = new Digio(config);
const documentId = "<document_id>";
const identifier = "<email_or_phone>";
const digioResponse: DigioResponse = await digio.start(documentId, identifier);
```

### 结束网关事件\[可选\]

您可以消耗事件, 并了解用户在进行时的流量或行程 .

关于事件及其相关有效载荷的完整清单,请参见: [这里](https://docs.google.com/document/d/15LHtjGyXd_JNM0de8uH9zB7WllJikRl1d9e4qdy0-C0/edit?usp=sharing)

```tsx
import { useEffect } from 'react';
import { Digio, DigioConfig, GatewayEvent, ServiceMode } from '@digiotech/react-native';

function YourComponent() {
  useEffect(() => {
    const gatewayEventListener = digio.addGatewayEventListener(
      (event: GatewayEvent) => {
        // Do some operation on the received events
      }
    );

    return () => {
      gatewayEventListener.remove();
    }
  }, []);
}
```

### 完成使用

```tsx
import { useEffect } from 'react';
import { Digio, DigioConfig, GatewayEvent, ServiceMode } from '@digiotech/react-native';

function YourComponent() {
  useEffect(() => {
    const gatewayEventListener = digio.addGatewayEventListener(
      (event: GatewayEvent) => {
        // Do some operation on the received events
      }
    );

    return () => {
      gatewayEventListener.remove();
    }
  }, []);

  const triggerDigioGateway = async () => {
    const config: DigioConfig = { environment: Environment.PRODUCTION, serviceMode: ServiceMode.OTP, isGlobal: false };
    const digio = new Digio(config);
    const documentId = "<document_id>";
    const identifier = "<email_or_phone>";
    const tokenId = "<gateway_token_id";
    const digioResponse: DigioResponse = await digio.start(documentId, identifier, tokenId);

  }
}
```

## 机器人

-   Digio SDK 支持和机器人版本 8( SDK 级别 26) 及以上
-   在构建下的工程中添加下面. gradle(模块:app)文件

```tsx
// Required for esign/mandate sign
implementation 'com.github.digio-tech:protean-esign:v3.12'
// under android {} of build.gradle(module:app)
 buildFeatures {
    viewBinding true
    dataBinding true
  }

// Make sure your project using
    compileSdkVersion = 35
    targetSdkVersion = 35
```

## SDK 参考

### Digioconfig 函数

**参数:**

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| 环境\* | 字符串 | 您想要打开网关的环境 。 一个 `sandbox` 或者说 `production` |
| 标志 | 字符串 | 通过您品牌标志的 URL . **说明:** 通过一个最佳图像url以获取最佳效果 |
| 主题 | 字符串 | 更改网关外观的选项 。 其下的选项见下文. |
| 服务模式\* | 字符串 | 服务模式可以是OTP/FACE/IRIS/FP < Default it's Opt>,您可以根据请示设置 |

**主题:**

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| 初等颜色 | 字符串 | 您的品牌颜色是 HEX 代码来改变 CTA( 呼叫到动作) 按钮颜色 |
| 中学 | 字符串 | 更改文本颜色的 HEX 代码 |
| 字体家庭 | 字符串 | 你选择的字体家庭。 用于: Crimson Pro |
| 字体格式 | 字符串 | 提供的字体家庭格式 。 像是: " woff2 " 、 " ot " 、 " not " |
| 字体Url | 字符串 | 字体家族 URL。 用于“ {font family url}. woff2> |

### DigioResponse \[从网关收到的回复\]

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| 代码\* | 编号 | 超过1001美元  
误报=1002  
出口 = - 1 000  
WEBVIEW CRASH = 1003 (韩语)  
WEBVIEW 错误=10017  
SDK CRASH = 1004  
地点/卡梅拉/MicroPhone许可被用户拒绝=1008 |
| 文档编号 | 字符串 | 从父应用程序传出的文件 ID 。 用于: `KID22040413040490937VNTC6LAP8KWD` |
| 消息 | 字符串 | 发生崩溃或失败时的错误信息 |
| 权限 | 阵列 | Kyc 行程中未给予的强制许可列表 |

### Android 权限

在清单文件中添加所需的权限 。 说明- 这是各种 KYC 流常见的 SDK

```
<!--RECORD_AUDIO and MODIFY_AUDIO_SETTINGS Permission required for Video KYC -->
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
/** Required for geotagging */
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

/** Required for ID card analysis, selfie and face match**/
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera.autofocus"   android:required="false" />

<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />


```

一个fintech Android app不能访问以下权限

-   读取 外部 存储
-   读取图像( M)
-   读取联系人
-   访问 fine 位置
-   读取 手机 数字
-   读取 media videos

## 由于主题问题,您会遇到一个构建错误 .

-   请在您的机器人清单下添加工具: 重置="和机器人:主题".

```
 <application
      ....
      tools:replace="android:theme"
      ...
      >
      .....
    </application>

```

## 由于重复的类和机器人.support,你得到一个构建错误. 页:1

-   请检查date=中的日期值 (帮助).

```
android.enableJetifier=true
reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64

```

### IOS 权限

-   Digio SDK 支持 iOS 15.6 及以上 权限需要添加到您的信息中 。 列表

```
  /**  Camera permission incase of selfie/video KYC/ capture document  **/
  <key>NSCameraUsageDescription</key>
  <string>$(PRODUCT_NAME) would like to access your camera.</string>
  <key>NSPhotoLibraryUsageDescription</key>
  <string>$(PRODUCT_NAME) would like to access your photo.</string>
  /**  Microphone permission incase of video KYC  **/
  <key>NSMicrophoneUsageDescription</key>
  <string>$(PRODUCT_NAME) would like to access your microphone to capture video.</string>
  /** Location permission for geo tagging for camera/video kyc/ selfie **/
  <key>NSLocationWhenInUseUsageDescription</key>
  <string>$(PRODUCT_NAME) would like to access your location.</string>
  <key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
  <string>$(PRODUCT_NAME) would like to access your location.</string>
```

注:所有权限在触发 Digio SDK 之前都应检查和取用

### 在您的 iOS 应用程序的 Info. plist 文件中添加 LSAplication 查询计划

```
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>phonepe</string>
        <string>gpay</string>
        <string>paytmmp</string>
        <string>bhim</string>
        <string>upi</string>
        <string>ppe</string>
    </array>
```

### 护卫:

需要测试释放结构,以便在释放前提出可能的例外.

```
-keepattributes SourceFile,LineNumberTable
-keep public class * extends java.lang.Exception
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes JavascriptInterface
-keepattributes *Annotation*
-keepattributes Signature
-optimizations !method/inlining/*
-keeppackagenames
-keepnames class androidx.navigation.fragment.NavHostFragment
-keep class * extends androidx.fragment.app.Fragment{}
-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-dontwarn androidx.databinding.**
-keep class androidx.databinding.** { *; }
-keepclassmembers class * extends androidx.databinding.** { *; }
-dontwarn org.json.**
-keep class org.json** { *; }
-keep public class org.simpleframework.**{ *; }
-keep class org.simpleframework.xml.**{ *; }
-keep class org.simpleframework.xml.core.**{ *; }
-keep class org.simpleframework.xml.util.**{ *; }
-dontwarn com.google.android.gms.**
-keep class com.google.android.gms.** { *; }
-keep class com.google.android.material.** { *; }
-dontwarn org.simpleframework.**
-keepattributes ElementList, Root
-keepclassmembers class * {
    @org.simpleframework.xml.* *;
}
-keep class org.spongycastle.** { *; }
-keep class com.ecs.rdlibrary.request.** { *; }
-keep class com.ecs.rdlibrary.response.** { *; }
-keep class com.ecs.rdlibrary.utils.** { *; }
-keep class com.ecs.rdlibrary.ECSBioCaptureActivity { *; }
-keep class org.simpleframework.xml.** { *; }
-keepattributes Exceptions, InnerClasses
-keep class com.google.android.gms.location.LocationSettingsRequest$Builder { *; }
-keepnames class ** { *; }
-keepclassmembers class * {
    @android.webkit.JavascriptInterface <methods>;
}
-keepattributes RuntimeVisibleAnnotations, RuntimeVisibleParameterAnnotations
-keepattributes AnnotationDefault
-keepclassmembers,allowshrinking,allowobfuscation interface * {
    @retrofit2.http.* <methods>;
}
-dontwarn javax.annotation.**
-dontwarn kotlin.Unit
-dontwarn retrofit2.KotlinExtensions
-dontwarn retrofit2.KotlinExtensions$*
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface <1>
-if interface * { @retrofit2.http.* <methods>; }
-keep,allowobfuscation interface * extends <1>
-keep,allowobfuscation,allowshrinking class kotlin.coroutines.Continuation
-if interface * { @retrofit2.http.* public *** *(...); }
-keep,allowoptimization,allowshrinking,allowobfuscation class <3>
-keep,allowobfuscation,allowshrinking class retrofit2.Response
-adaptresourcefilenames okhttp3/internal/publicsuffix/PublicSuffixDatabase.gz
-dontwarn org.codehaus.mojo.animal_sniffer.*
-dontwarn okhttp3.internal.platform.**
-dontwarn org.conscrypt.**
-dontwarn org.bouncycastle.**
-dontwarn org.openjsse.**
-keep class * extends androidx.databinding.DataBinderMapper
-dontwarn kotlin.jvm.internal.SourceDebugExtension

-dontwarn org.xmlpull.v1.**
-keep class org.xmlpull.v1.** { *; }
-keep class in.digio.sdk.gateway.interfaces.FeatureRegistrationInterface$DefaultImpls { *; }

-keep class javax.xml.bind.annotation.** { *; }
-dontwarn javax.xml.bind.annotation.**
-keep class com.ecs.cdslxsds.ESignProcessorResponse { *; }

-dontwarn org.xmlpull.v1.XmlPullParser
-dontwarn android.content.res.XmlResourceParser

-keep class in.digio.sdk.gateway.interfaces.FeatureRegistrationInterface$DefaultImpls { *; }
-dontwarn java.lang.invoke.StringConcatFactory
-keep public class com.digio.two_way_sdk.** {
    public *;
}
-keep class com.digio.two_way_sdk.** { *; }
-keep class androidx.databinding.** { *; }
-keep class androidx.viewbinding.** { *; }
-keep public class * extends androidx.**
-keep public class com.google.android.material.** { *; }
-keep public class androidx.** { public *; }


#emudhra
-keep class com.emudhra.** { *; }
-keep interface com.emudhra.** { *; }
-keepclassmembers class com.emudhra.** {
    native <methods>;
}
-dontwarn com.emudhra.**

# Jackson dataformat XML (used by emudhra at runtime via XmlMapper)
-keep class com.fasterxml.jackson.** { *; }
-keepnames class com.fasterxml.jackson.** { *; }
-dontwarn com.fasterxml.jackson.**

# Woodstox - StAX implementation backing jackson-dataformat-xml.
# FactoryFinder uses Class.forName via META-INF/services lookup; the impl
# classes must not be obfuscated or shrunk away.
-keep class com.ctc.wstx.** { *; }
-keep class org.codehaus.stax2.** { *; }
-dontwarn com.ctc.wstx.**
-dontwarn org.codehaus.stax2.**

# StAX API surfaces referenced via reflection
-keep class javax.xml.stream.** { *; }
-dontwarn javax.xml.stream.**
-keep class * implements javax.xml.stream.XMLInputFactory
-keep class * implements javax.xml.stream.XMLOutputFactory
-keep class * implements javax.xml.stream.XMLEventFactory

-keepattributes Signature, *Annotation*, EnclosingMethod, InnerClasses

```

## 常见问题

### @digiotech/react-native 是什么？

Digio React Independent SDK用于引用客户端的行程,如KYC,Selfie,Authority,RPD等Digio工作流程\.

### 如何安装 @digiotech/react-native？

在项目目录运行 npm install @digiotech/react-native，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（\*）、react-native（\*）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @digiotech/react-native 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @digiotech/react-native 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @digiotech/react-native 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>= 18\.0\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @digiotech/react-native 可以商用吗？

@digiotech/react-native 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @digiotech/react-native 的下载量有多少？

根据 npm 官方下载统计，@digiotech/react-native 在 2026/10/12 – 2026/11/10 这 30 天内被下载 6,231 次，日均约 208 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @digiotech/react-native 还在维护吗？

最新版本 2\.0\.20 发布于 2026/11/10（1 天前）；至今共发布 50 个版本，其中过去 12 个月发布了 23 个；首次发布于 2023/10/27。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

