@clickterm/react-native-sdk

中文文档
1.5.0发布于 2026/10/23MITTypeScriptCommonJS零依赖近 30 天下载 4430

React Native SDK for Clickterm clickwrap agreements.

原始使用文档
文档目录10 节
  1. Requirements
  2. Installation
  3. iOS
  4. Android
  5. Expo config plugin
  6. Usage
  7. API
  8. Errors
  9. License
  10. Document delivery recipient

@clickterm/react-native-sdk

React Native SDK for Clickterm clickwrap agreements. It presents native clickwrap dialogs in bare React Native and Expo apps by wrapping the native iOS and Android Clickterm SDKs as an Expo Module — no custom native bridges required.

Requirements

  • React Native 0.75+ or Expo SDK 52+
  • iOS 15.0+
  • Android minSdk 24

Installation

npm install @clickterm/react-native-sdk

iOS

Install the CocoaPods dependencies (bare React Native):

cd ios && pod install

Expo projects pick the module up automatically during npx expo prebuild or EAS Build. The native iOS framework is downloaded for you at this step — no manual setup is required.

Android

The native dependency is resolved automatically from Maven Central. Expo prebuilds also enable the core-library desugaring required for Android API 24 and 25 through the package's config plugin.

For a bare React Native app that does not run the config plugin, add the following to the app module's android/app/build.gradle:

android {
  compileOptions {
    coreLibraryDesugaringEnabled true
  }
}

dependencies {
  coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
}

Expo config plugin

Add the package to your app's plugins array so Expo CLI and EAS Build include it during prebuild:

// app.json
{
  "expo": {
    "plugins": ["@clickterm/react-native-sdk"]
  }
}

Usage

import * as Clickterm from '@clickterm/react-native-sdk';

await Clickterm.initialize('YOUR_APP_ID');

const signature = await Clickterm.show({
  clickwrapTemplateId: 'tmpl_abc',
  endUserId: 'user_42',
   templatePlaceholders: {
    fullName: 'Ada Lovelace',
    company: 'Analytical Engines Ltd',
    customPlaceholders: { customerName: 'Ada' },
  },
  language: 'en-US',
});

const bundleSignature = await Clickterm.showBundle({
  clickwrapBundleId: 'bundle_abc',
  endUserId: 'user_42',
  templatePlaceholdersByTemplateId: {
    tmpl_abc: {
      fullName: 'Ada Lovelace',
      company: 'Analytical Engines Ltd',
    },
  },
  language: 'en-US',
});

const accepted = await Clickterm.showAcceptedContent({
  clickwrapTemplateId: 'tmpl_abc',
  endUserId: 'user_42',
});

API

FunctionReturnsDescription
initialize(appId, environment?)Promise<void>Configure the SDK. environment is 'production' (default) or 'development' — see Platform differences.
show(request)Promise<string | null>Present the clickwrap dialog. Resolves with the signature string, or null if the user has already acted on the agreement.
showBundle(request)Promise<string | null>Present a bundle dialog. Resolves with the bundle signature, or null when every item was already accepted.
showAcceptedContent(request)Promise<ClickwrapTemplateContent>Re-display a previously accepted agreement and resolve with its stored content.

Request shapes (full TypeScript definitions ship with the package):

  • ClickwrapTemplateRequest — { clickwrapTemplateId, endUserId, templatePlaceholders?, language }
  • ClickwrapBundleRequest — { clickwrapBundleId, endUserId, templatePlaceholdersByTemplateId?, language? }
  • ClickwrapAcceptedAgreementRequest — { clickwrapTemplateId, endUserId }

showBundle() stays pending while the native dialog offers a retry after a load or submission error. It resolves when the flow succeeds or the bundle is already accepted, and rejects when the user cancels or the flow ends with a terminal error.

Errors

All methods reject with an Error whose code property is one of:

CodeMeaning
ERR_CLICKTERM_NOT_INITIALIZEDinitialize() was not called first.
ERR_CLICKTERM_INVALID_ARGUMENTA required argument is missing or malformed.
ERR_CLICKTERM_NETWORKThe request could not reach the server.
ERR_CLICKTERM_HTTPThe server responded with an error status.
ERR_CLICKTERM_DECODINGThe server response could not be parsed.
ERR_CLICKTERM_USER_CANCELLEDThe user dismissed the dialog.
ERR_CLICKTERM_NO_PRESENTERiOS: no view controller was available to present from.
ERR_CLICKTERM_NO_ACTIVITYAndroid: no foreground activity was available.
ERR_CLICKTERM_UNKNOWNAn unexpected error occurred.

License

MIT

Document delivery recipient

Pass an optional ddRecipient (email, optional fullName) with the template or bundle request. This is separate from document placeholders. A bundle uses one recipient for the entire delivery email. Enable agreement email delivery in ClickTerm. Missing or invalid email addresses produce skipped deliveries; placeholder emails are never used as a fallback. Email supports up to 254 characters and fullName up to 100.

const ddRecipient = { email: '[email protected]', fullName: 'Alice Example' };
await show({ clickwrapTemplateId: 'template', endUserId: 'user', ddRecipient });
await showBundle({ clickwrapBundleId: 'bundle', endUserId: 'user', ddRecipient });

Verification uses the recipient supplied with the request; it cannot add, replace, or clear it. Do not send ddRecipient at Verify. Verification belongs on your backend; the React Native SDK never sends backend credentials or calls Verify. The React Native wrapper does not currently expose deferred identity or activation. Its recipient is supplied only with the normal template or bundle request.

版本与发布记录

@clickterm/react-native-sdk 共发布 13 个版本,首次发布于 2026/05/28;过去 12 个月发布了 13 个版本。

版本发布日期距今
1.5.0latest2026/10/2317 天前
1.4.02026/09/181 个月前
1.3.02026/08/282 个月前
1.2.02026/07/203 个月前
1.1.02026/06/194 个月前
1.0.02026/06/174 个月前

关于 @clickterm/react-native-sdk 的常见问题

@clickterm/react-native-sdk 是什么?

React Native SDK for Clickterm clickwrap agreements.

如何安装 @clickterm/react-native-sdk?

在项目目录运行 npm install @clickterm/react-native-sdk,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:expo(*)、react(*)、react-native(*)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@clickterm/react-native-sdk 支持 TypeScript 吗?

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

@clickterm/react-native-sdk 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@clickterm/react-native-sdk 可以商用吗?

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

@clickterm/react-native-sdk 的下载量有多少?

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

@clickterm/react-native-sdk 还在维护吗?

最新版本 1.5.0 发布于 2026/10/23(17 天前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/05/28。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。