@clickterm/react-native-sdk
v1.1.0
Published
React Native SDK for Clickterm clickwrap agreements.
Maintainers
Readme
@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 SDK52+ - iOS
15.0+ - Android
minSdk 24
Installation
npm install @clickterm/react-native-sdkiOS
Install the CocoaPods dependencies (bare React Native):
cd ios && pod installExpo 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
No additional steps — the native dependency is resolved automatically from Maven Central.
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 accepted = await Clickterm.showAcceptedContent({
clickwrapTemplateId: 'tmpl_abc',
endUserId: 'user_42',
});API
| Function | Returns | Description |
|---|---|---|
| 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. |
| 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 }ClickwrapAcceptedAgreementRequest—{ clickwrapTemplateId, endUserId }
Errors
All methods reject with an Error whose code property is one of:
| Code | Meaning |
|---|---|
| ERR_CLICKTERM_NOT_INITIALIZED | initialize() was not called first. |
| ERR_CLICKTERM_INVALID_ARGUMENT | A required argument is missing or malformed. |
| ERR_CLICKTERM_NETWORK | The request could not reach the server. |
| ERR_CLICKTERM_HTTP | The server responded with an error status. |
| ERR_CLICKTERM_DECODING | The server response could not be parsed. |
| ERR_CLICKTERM_USER_CANCELLED | The user dismissed the dialog. |
| ERR_CLICKTERM_NO_PRESENTER | iOS: no view controller was available to present from. |
| ERR_CLICKTERM_NO_ACTIVITY | Android: no foreground activity was available. |
| ERR_CLICKTERM_UNKNOWN | An unexpected error occurred. |
License
MIT
