# Overview

The `cordova-plugin-idv` package is the Cordova SDK for Mosaic Identity Verification. It guides the user through document capture, selfie capture, and face authentication, and reports progress to JavaScript on `cordova.tsidv` after the `deviceready` event.

## Capabilities

- Document and selfie capture for identity verification
- Face authentication
- Mosaic UI experience, which adds guidance screens
- Status listeners for flow progress


## Requirements

- `cordova-ios` 8.0.0 or higher, iOS 13.0 or higher, Xcode 16 or higher
- `cordova-android` 14.0.0 or higher, JDK 17 for the build


Important
The plugin pins the native Identity Verification SDK at 1.3.7. That SDK brings Fraud Prevention 3.x and the core SDK 1.1.x with it (Android `com.ts.sdk:accountprotection` 3.0.3 and `com.ts.sdk:core` 1.1.2; iOS `AccountProtection` 3.0.9 or later and `TSCoreSDK` 1.1.6 or later). If the app also uses a Mosaic plugin or SDK built on Fraud Prevention 2.x or core 1.0.x, update that plugin or SDK as well. Selecting a different Identity Verification version requires a new release of this plugin.

## Installation

```shell
cordova plugin add https://github.com/TransmitSecurity/cordova_ts_idv_plugin.git#v1.0.0
```

To change the text of the iOS camera permission prompt, pass it when adding the plugin:

```shell
cordova plugin add https://github.com/TransmitSecurity/cordova_ts_idv_plugin.git#v1.0.0 \
  --variable CAMERA_USAGE_DESCRIPTION="We use the camera to verify your identity."
```

The plugin adds the camera permission on both platforms. On iOS, Xcode resolves the native SDK through Swift Package Manager on the first build. On Android, the plugin adds the Transmit Security Maven repository.

## Platform configuration

iOS
The plugin sets `NSCameraUsageDescription`. The default text is `This app uses the camera to capture your ID document and a selfie for identity verification.` Override it with the `CAMERA_USAGE_DESCRIPTION` variable in the install command above.

Android
The plugin adds the `INTERNET`, `ACCESS_NETWORK_STATE`, and `CAMERA` permissions, and the Transmit Security Maven repository.

`after_prepare` hooks re-enable Kotlin compilation (Cordova turns it off on every prepare) and pin the Gradle wrapper. Both run on `cordova prepare`.

If the app minifies its release build, add this rule to the ProGuard / R8 configuration. The native SDK references `kotlinx.parcelize.Parcelize` without shipping a rule for it, and the app does not need the `Parcelize` annotation at runtime.

```
-dontwarn kotlinx.parcelize.Parcelize
```

## Credentials

`initializeSDK()` reads credentials from a native config file. `initialize(clientId, baseUrl)` takes them in JavaScript. Use one of the two. For `initializeSDK()`, add the files below. Replace `CLIENT_ID` with your client ID.

iOS
Create `res/ios/TransmitSecurity.plist` and ship it as a resource:

```xml
<platform name="ios">
    <resource-file src="res/ios/TransmitSecurity.plist" target="TransmitSecurity.plist" />
</platform>
```

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>credentials</key>
    <dict>
        <key>baseUrl</key>
        <string>https://api.transmitsecurity.io</string>
        <key>clientId</key>
        <string>CLIENT_ID</string>
    </dict>
</dict>
</plist>
```

`configurationFileName` selects another plist, without its extension.

Android
Create `res/android/transmit_security.xml`:

```xml
<platform name="android">
    <resource-file src="res/android/transmit_security.xml"
                   target="app/src/main/res/values/transmit_security.xml" />
</platform>
```

```xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="transmit_security_client_id">CLIENT_ID</string>
    <string name="transmit_security_base_url">https://api.transmitsecurity.io</string>
</resources>
```

Passing `configurationFileName` to `initializeSDK()` rejects with `notSupported`. Android always reads the `transmit_security_*` string resources.

`baseUrl` is the Mosaic API host. Set a URL from the table in the configuration files, or pass that URL to `initialize()`. For the US, EU, and Canada hosts, you can pass a [BaseURL](/sdk-ref/cordova-ts-idv/enums/baseurl) constant instead: `cordova.tsidv.BaseURL.us`, `BaseURL.eu`, or `BaseURL.ca`. When you omit `baseUrl`, the plugin uses the US host.

| Region | Base URL |
|  --- | --- |
| US | `https://api.transmitsecurity.io` |
| EU | `https://api.eu.transmitsecurity.io` |
| Canada | `https://api.ca.transmitsecurity.io` |
| Australia | `https://api.au.transmitsecurity.io` |
| Japan | `https://api.gasne1-ts01.transmitsecurity.io` |
| Sandbox | `https://api.sbx.transmitsecurity.io` |
| Custom domain | `https://<your-custom-domain>` (see [Custom domains](/guides/deployment/custom_domains)) |


## Initialization

`cordova.tsidv` is available after the `deviceready` event. Register a status listener before you start a flow. Statuses that arrive before the first listener is registered are delivered to it. A start call resolves when the flow is launched. The outcome arrives through the listener.

```javascript
document.addEventListener('deviceready', async () => {
  const idv = cordova.tsidv;

  const subscription = idv.addStatusListener(({ status, additionalData }) => {
    switch (status) {
      case idv.Status.verificationDidComplete:
        // Get the verification result from your backend.
        break;
      case idv.Status.verificationRequiresRecapture:
        // additionalData.errorCode is a RecaptureReasonCode.
        idv.recapture();
        break;
      case idv.Status.verificationDidFail:
        console.log('Verification failed: ' + additionalData.errorCode);
        break;
    }
  });

  await idv.initializeSDK();
  // or: await idv.initialize('CLIENT_ID', idv.BaseURL.us);
  // or: await idv.initialize('CLIENT_ID', 'https://api.sbx.transmitsecurity.io');

  const cameraGranted = await idv.requestCameraPermission();
  if (!cameraGranted) {
    // Explain why the camera is needed and send the user to Settings.
    return;
  }

  await idv.startIdentityVerification(startToken);
}, false);
```

Get the start token by creating a verification session from your backend. See [Create session](/guides/verify/quick_start_ios#step-7-create-session). For face authentication, create a face authentication session and pass its device session ID to `startFaceAuth`. See [Create session](/guides/user/auth_face#step-8-create-session).

## Behavior

- Every start first fetches the SDK configuration from your tenant. If that fails, the flow fails with `configFetchError`, or with `sdkDisabled` when the SDK is turned off for the tenant.
- Initialize before starting a flow. Calling an init method again is safe, but on iOS it does not change the client ID or base URL. The first initialization stays in effect until the app restarts.
- Start one flow at a time. The SDK ignores a start call while a Mosaic UI flow is still on screen, and on iOS that call stops the Mosaic UI flow from reporting its statuses.
- `initializationError` and `recaptureNotRequired` are reported only by iOS. The other `errorCode` values are the same on iOS and Android.
- A completed status means the user finished the flow and the data was processed. Get the result from your backend.


## Known issues

- iOS: if the configuration fetch fails when a Mosaic UI flow starts, no `mosaicUIVerificationDidFail` status is sent. The SDK shows its error screen, and later flows report their statuses as usual.


- iOS: in apps built with Xcode 27, the app can crash if the SDK requests camera access itself. Call `requestCameraPermission()` and start a flow only when it resolves `true`.


## Next steps

Call the [Identity Verification functions](/sdk-ref/cordova-ts-idv/functions) to initialize the SDK, start a flow, and handle status events.