Capacitor plugin

Start your integration with Capacitor plugin.

Latest release: Version 1.47.1 (Changelog)

Installation

  1. Add the plugin to your project.

    npm install @sumsub/capacitor-idensic-mobile-sdk-plugin
  1. Run the following command.

    npx cap sync

Android

Important

  • Use Capacitor 8 or higher.
  • Use API level 24 (Android 7.0) or higher.

The plugin adds the Sumsub Maven repository to your build and declares the required permissions automatically, so no additional setup is required.

Note

If your android/settings.gradle declares dependencyResolutionManagement with the FAIL_ON_PROJECT_REPOS mode, add the repository there yourself.

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url "https://maven.sumsub.com/repository/maven-public/" }
    }
}

iOS

Important

  • Use iOS 15.0 or higher.
  • The plugin is distributed via Swift Package Manager, the default for Capacitor 8 iOS projects. If your project still uses CocoaPods, migrate it to SPM first.

Update Info.plist to have a description for the usage of the camera, microphone, photo library, and geolocation.

plutil -insert "NSCameraUsageDescription" -string "Let us take a photo" ios/App/App/Info.plist
plutil -insert "NSMicrophoneUsageDescription" -string "Time to record a video" ios/App/App/Info.plist
plutil -insert "NSPhotoLibraryUsageDescription" -string "Let us pick a photo" ios/App/App/Info.plist
plutil -insert "NSLocationWhenInUseUsageDescription" -string "Please provide us with your geolocation data to prove your current location" ios/App/App/Info.plist

Modules

Each optional module is a separate npm package that works on both Android and iOS. The SDK detects the installed modules at runtime, so there is no API to call.

Important

  • A module package requires exactly the same version as the plugin, so always upgrade them together.

    npm install @sumsub/[email protected] @sumsub/[email protected]
    npx cap sync
  • Keep @sumsub/capacitor-idensic-mobile-sdk-plugin in the dependencies of your package.json, as npx cap sync only adds the direct dependencies of the app to the native projects.

Device Intelligence

The Device Intelligence functionality is optional, but highly recommended as it provides an additional layer of security during the verification process. It analyzes device attributes, configuration patterns, and runtime signals to detect anomalies associated with fraudulent activity.

In order to use it, you need to add the module as shown below and enable the functionality with your dashboard.

Installation

Run the following commands.

npm install @sumsub/capacitor-idensic-mobile-sdk-fisherman
npx cap sync

Android

No additional setup is required.

iOS

No additional setup is required.

MRTDReader (NFC)

The MRTDReader is an optional module that allows the SDK to detect and read the electronic chips placed on MRTD documents via NFC.

Installation

Run the following commands.

npm install @sumsub/capacitor-idensic-mobile-sdk-nfc
npx cap sync

Android

No additional setup is required.

iOS

  1. Open up the iOS project in Xcode.

    npx cap open ios
  2. Turn on the Near Field Communication Tag Reading capability for your project target.
  1. Add to the application Info.plist file.

    <key>NFCReaderUsageDescription</key>
    <string>Let us scan the document for more precise recognition</string>
    <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
    <array>
        <string>A0000002471001</string>
        <string>A0000002472001</string>
        <string>00000000000000</string>
    </array>

VideoIdent

The VideoIdent is an optional module that is required only if you are going to use the Video identification during the verification flow.

Installation

Run the following commands.

npm install @sumsub/capacitor-idensic-mobile-sdk-videoident
npx cap sync

Android

No additional setup is required.

iOS

  1. Open up the iOS project in Xcode.

    npx cap open ios
  2. Add the Background mode capability for your project target and select the Audio, AirPlay, and Picture in Picture option required for the video call not to be broken when the application goes into the background.

eID

The EID is an optional module required only if you are going to use "eID Verification" during the verification flow.

Installation

Run the following commands.

npm install @sumsub/capacitor-idensic-mobile-sdk-eid
npx cap sync

Android

  1. Add the private Maven repository with the credentials to the allprojects block in android/build.gradle. You can obtain the credentials through our support team.

    allprojects {
        repositories {
            google()
            mavenCentral()
            maven {
                url "https://maven.sumsub.com/repository/maven-private/"
                credentials {
                    username = "..."
                    password = "..."
                }
            }
        }
    }

    If your android/settings.gradle declares dependencyResolutionManagement with the FAIL_ON_PROJECT_REPOS mode, add the repository to its repositories block instead.

iOS

  1. Add credentials for a private Maven repository into your ~/.netrc file. You can obtain the credentials through our support team. The file is required on every machine that resolves the Swift packages, including CI.

    machine maven.sumsub.com
    login ...
    password ...
  1. Open up the iOS project in Xcode.

    npx cap open ios
  2. Turn on the Near Field Communication Tag Reading capability for your project target.
  3. Add to the application Info.plist file.

    <key>NFCReaderUsageDescription</key>
    <string>Let us scan the eID card to verify your identity</string>
    <key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
    <array>
        <string>A0000002471001</string>
        <string>E80704007F00070302</string>
    </array>

    If you also use the MRTDReader module, list the identifiers of both modules in a single select-identifiers array.

Usage

Important

Before launching, make sure you have configured your verification level and access token.

Launch

import SNSMobileSDK from '@sumsub/capacitor-idensic-mobile-sdk-plugin';

// From your backend, get an access token for the applicant to be verified.
// The token must be generated with `levelName` and `userId`,
// where `levelName` is the name of a level configured in your dashboard.
//
// The SDK will work in the production or in the sandbox environment
// depend on which one the `accessToken` has been generated on.
//
let accessToken = 'your_access_token';

let snsMobileSDK = SNSMobileSDK.init(accessToken, async () => {
    // this is a token expiration handler. It will be called if the provided token is invalid or got expired
    // call your backend to fetch a new access token (this is just an example)
    return 'new_access_token';
  })
  .withHandlers({ // Optional callbacks you can use to get notified of the corresponding events
    onStatusChanged: (event) => {
      console.log("onStatusChanged: [" + event.prevStatus + "] => [" + event.newStatus + "]");
    }
  })
  .withDebug(true)
  .withLocale('en') // Optional, for cases when you need to override the system locale
  .build();

snsMobileSDK.launch().then(result => {
  console.log("Sumsub SDK State: " + JSON.stringify(result))
}).catch(err => {
  console.log("Sumsub SDK Error: " + err)
});

The snsMobileSDK.launch() returns a Promise that will be resolved with the Result object once the SDK is closed. Use it to determine the SDK status upon its closure. The Promise is rejected only if the SDK cannot be launched, for example, when another SDK instance is still running.

Here is an example of the result.

{
  "success": false,
  "status": "Failed",
  "errorType": "Unauthorized",
  "errorMsg": "Unauthorized access with accessToken=[your access token]"
}

Dismissal

By default, once the applicant is approved, the SDK will be dismissed in 3 seconds automatically. You can adjust this time interval or switch the automatic dismissal off by setting the value to zero.

.withAutoCloseOnApprove(0)

Also, in case you need to close the SDK programmatically, here is what you can do.

snsMobileSDK.dismiss()

Advanced

Configuration

If it is required, you can provide an email and/or phone number that will be assigned to the applicant initially.

.withApplicantConf({
  "email": "...",
  "phone": "..."
})

Preferred documents

For IDENTITY* steps, it is possible to specify the preferred country and document type to be selected automatically, bypassing the DocType Selector screen.

Note that the parameters provided will be applied only if the corresponding combination of country and idDocType is allowed at the step according to the level configuration.

.withPreferredDocumentDefinitions({
  "IDENTITY": {
    "idDocType":"PASSPORT",
    "country":"USA"
  },
  "IDENTITY2": {
    "idDocType":"DRIVERS",
    "country":"FRA"
  }
})

Localization

You can customize or localize the texts used within the SDK in Configurations → SDK customization → SDK text in the Dashboard.

The language will be set according to the system locale, but you can override it with the locale you desire.

.withLocale("en")

For a complete list of supported locales, see this article.

Strings

In addition to the SDK text settings and .withLocale, you can use .withStrings option that allows you to define the strings locally.

This may be helpful for iOS apps if you would like to avoid the Wordless Oops screen that could be rendered in case the network happens to be down during the SDK initialization, and force the SDK to draw the Network Oops screen instead.

.withStrings({
  "sns_oops_network_title": "Oops! Seems like the network is down.",
  "sns_oops_network_html": "Please check your internet connection and try again.",
  "sns_oops_action_retry": "Try again",
})

Note that .withLocale does not affect these strings, thus it is up to you to use the required localization.

Analytics

The SDK collects and sends usage data to Sumsub servers. We do not track any sensitive data. Only general usage statistics are sent to us. It includes screen navigation events, UI controls interaction events, and so on.

We interpret the usage data in order to improve Sumsub. None of the data is sold or transferred to third parties, and we do not use it for advertising.

If you still want to disable this feature, you can use the following to do this.

.withAnalyticsEnabled(false)

Events

Various events happening along the processing can be delivered into an optional onEvent handler.

.withHandlers({
  onEvent: (event) => {
    console.log("onEvent: " + JSON.stringify(event));
  }
})

Each Event has eventType and some parameters packed into payload hash, for example:

{
  "eventType": "StepInitiated",
  "payload": {
    "idDocSetType": "IDENTITY"
  }
}

Possible events

eventTypepayloadDescription
"ApplicantLoaded"
{
"applicantId": "$applicantId"
}
Applicant $applicantId has been loaded.
"StepInitiated"
{
"idDocSetType": "$idDocSetType"
}
Step $idDocSetType has been initiated.
"StepCompleted"
{
"idDocSetType": "$idDocSetType",
"levelName": "$levelName",
"isCancelled": false
}
Step $idDocSetType at level $levelName has been fulfilled or cancelled.
"Analytics"
{
"eventName": "$eventName",
"eventPayload": object
}
Analytics event $eventName has occurred.

The list is not exhaustive.

Applicant Actions

To run the SDK in Applicant actions mode, you need to have:

  1. A verification level with the Applicant actions type.
  2. An access token created with the userId, levelName, and externalActionId parameters.

Aside from the notes above, use the SDK the same way that you do with regular levels.

Migration from Cordova plugin

If your Capacitor app uses the Cordova plugin, you can switch to the Capacitor plugin as follows:

  1. Remove @sumsub/cordova-idensic-mobile-sdk-plugin and install the Capacitor plugin as described in Installation.
  2. Install the module packages you need instead of the --with-* install options. On Android, the Cordova plugin included all the modules, so add the packages of the modules you use there as well.
  3. Import the plugin instead of using the SNSMobileSDK global.

    import SNSMobileSDK from '@sumsub/capacitor-idensic-mobile-sdk-plugin';

The builder methods, launch(), dismiss(), and the Result object are the same as in the Cordova plugin.

API Reference

Result

An object describing the outcome of the last SDK launch:

FieldTypeDescription
successBooleanBoolean value indicates if there was an error on the moment the SDK is closed. Use errorType and errorMsg to see the reasons for the error, if any.
statusStringSDK status.
errorTypeStringFormal reason of the error, if any.
errorMsgStringVerbose error description, if any.

While success and status are always present, the rest of the fields are optional.

Status

Here are the possible SDK statuses:

CaseDescription
ReadySDK is initialized and ready to be presented.
FailedSDK fails for some reasons (see errorType and errorMsg for details).
InitialNo verification steps have been passed yet.
IncompleteSome but not all of the verification steps have been passed over.
PendingVerification is pending.
TemporarilyDeclinedApplicant has been declined temporarily.
FinallyRejectedApplicant has been finally rejected.
ApprovedApplicant has been approved.

Error type

Here are the possible error types:

CaseDescription
UnknownUnknown or no fail.
InvalidParametersAttempt to set up with invalid parameters.
UnauthorizedUnauthorized access detected (most likely accessToken is invalid or expired and has failed to be refreshed).
InitialLoadingFailedInitial loading from the backend has failed.
ApplicantNotFoundNo applicant is found for the given parameters.
ApplicantMisconfiguredApplicant is found but is misconfigured (most likely lacks of idDocs).
InitializationErrorInitialization error occurred.
NetworkErrorNetwork error occurred (the user will be presented with the Network Oops screen).
UnexpectedErrorSome unexpected error occurred (the user will be presented with the Fatal Oops screen).

Event

An object that represents an event happening along the processing:

FieldTypeDescription
eventTypeStringEvent type.
payloadObjectEvent payload.

Did this page help you?