Skip to main content
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

OutcomePromise stateResolved value
User acceptsResolvedNon-null Signature string — send it to your backend
User declinesResolvedNon-null Signature string — verify it to record the decline
User already acceptedResolvednull — no dialog was shown, no action needed
ErrorRejectedN/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

CodeMeaning
ERR_CLICKTERM_NOT_INITIALIZEDinitialize() was not called (or did not resolve) before invoking another method.
ERR_CLICKTERM_INVALID_ARGUMENTA required field is missing or malformed (for example, an empty appId).
ERR_CLICKTERM_NETWORKThe device could not reach the ClickTerm API.
ERR_CLICKTERM_HTTPThe API responded with a non-success HTTP status.
ERR_CLICKTERM_DECODINGThe SDK could not decode the response payload.
ERR_CLICKTERM_USER_CANCELLEDThe user dismissed the dialog without acting on it.
ERR_CLICKTERM_NO_PRESENTERiOS only — no view controller was available to present the dialog.
ERR_CLICKTERM_NO_ACTIVITYAndroid only — no foreground Activity was available to host the dialog.
ERR_CLICKTERM_UNKNOWNAn 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.