The ClickTerm React Native SDK is Promise-based. show() and showAcceptedContent() return Promises that resolve on success and reject with an Error (carrying a .code property) on failure.
Show result
When show() completes:
import * as Clickterm from '@clickterm/react-native-sdk';
try {
const signature = await Clickterm.show(request);
if (signature !== null) {
// User accepted or declined — send Signature to your backend
await sendToBackend(signature);
} else {
// User already accepted the latest major version — no dialog was shown
console.log('Already accepted.');
}
} catch (error) {
// SDK or network error — inspect the code
console.error('Clickwrap error', error);
}
Possible outcomes
| Outcome | Promise state | Resolved value |
|---|
| User accepts | Resolved | Non-null Signature string — send it to your backend |
| User declines | Resolved | Non-null Signature string — verify it to record the decline |
| User already accepted | Resolved | null — no dialog was shown, no action needed |
| Error | Rejected | N/A — the rejection is an Error with a .code property |
A null Signature resolved from show() means the user has already accepted the latest major version. No action is needed on your part.
Error handling
Errors are thrown as standard Error instances with a non-standard code property whose value is one of the documented ClicktermErrorCode strings. Read code from the caught error to drive your application’s response:
function formatError(error: unknown): string {
if (error instanceof Error) {
const code = (error as { code?: string }).code;
return code ? `[${code}] ${error.message}` : error.message;
}
return String(error);
}
try {
await Clickterm.show(request);
} catch (error) {
console.error(formatError(error));
}
ClicktermErrorCode values
| Code | Meaning |
|---|
ERR_CLICKTERM_NOT_INITIALIZED | initialize() was not called (or did not resolve) before invoking another method. |
ERR_CLICKTERM_INVALID_ARGUMENT | A required field is missing or malformed (for example, an empty appId). |
ERR_CLICKTERM_NETWORK | The device could not reach the ClickTerm API. |
ERR_CLICKTERM_HTTP | The API responded with a non-success HTTP status. |
ERR_CLICKTERM_DECODING | The SDK could not decode the response payload. |
ERR_CLICKTERM_USER_CANCELLED | The user dismissed the dialog without acting on it. |
ERR_CLICKTERM_NO_PRESENTER | iOS only — no view controller was available to present the dialog. |
ERR_CLICKTERM_NO_ACTIVITY | Android only — no foreground Activity was available to host the dialog. |
ERR_CLICKTERM_UNKNOWN | An unexpected error occurred. Check the message for details. |
ERR_CLICKTERM_NO_PRESENTER and ERR_CLICKTERM_NO_ACTIVITY are platform-specific; you typically only see the one that matches the OS your app is running on.
Show accepted content result
showAcceptedContent() follows the same pattern: it resolves with the stored ClickwrapTemplateContent or rejects with an Error whose code is a ClicktermErrorCode.
try {
const content = await Clickterm.showAcceptedContent(request);
// content.content is the rendered HTML of the accepted agreement
console.log(content.title ?? '(untitled)');
} catch (error) {
console.error('showAcceptedContent() failed', error);
}
showAcceptedContent only works if the end user has an accepted and verified event for the given template.