Capacitor plugin
Start your integration with Capacitor plugin.
Latest release: Version 1.47.1 (Changelog)
Installation
-
Add the plugin to your project.
npm install @sumsub/capacitor-idensic-mobile-sdk-plugin
-
Run the following command.
npx cap sync
Android
The plugin adds the Sumsub Maven repository to your build and declares the required permissions automatically, so no additional setup is required.
NoteIf your
android/settings.gradledeclaresdependencyResolutionManagementwith theFAIL_ON_PROJECT_REPOSmode, 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.plistModules
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-pluginin the dependencies of yourpackage.json, asnpx cap synconly 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 syncAndroid
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 syncAndroid
No additional setup is required.
iOS
-
Open up the iOS project in Xcode.
npx cap open ios - Turn on the
Near Field Communication Tag Readingcapability for your project target.
-
Add to the application
Info.plistfile.<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 syncAndroid
No additional setup is required.
iOS
-
Open up the iOS project in Xcode.
npx cap open ios - Add the
Background modecapability for your project target and select theAudio, AirPlay, and Picture in Pictureoption 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 syncAndroid
-
Add the private Maven repository with the credentials to the
allprojectsblock inandroid/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.gradledeclaresdependencyResolutionManagementwith theFAIL_ON_PROJECT_REPOSmode, add the repository to itsrepositoriesblock instead.
iOS
-
Add credentials for a private Maven repository into your
~/.netrcfile. 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 ...
-
Open up the iOS project in Xcode.
npx cap open ios - Turn on the
Near Field Communication Tag Readingcapability for your project target. -
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
MRTDReadermodule, list the identifiers of both modules in a singleselect-identifiersarray.
Usage
ImportantBefore 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
| eventType | payload | Description |
|---|---|---|
"ApplicantLoaded" | { | Applicant $applicantId has been loaded. |
"StepInitiated" | { | Step $idDocSetType has been initiated. |
"StepCompleted" | { | Step $idDocSetType at level $levelName has been fulfilled or cancelled. |
"Analytics" | { | Analytics event $eventName has occurred. |
The list is not exhaustive.
Applicant Actions
To run the SDK in Applicant actions mode, you need to have:
- A verification level with the Applicant actions type.
- An access token created with the
userId,levelName, andexternalActionIdparameters.
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:
- Remove
@sumsub/cordova-idensic-mobile-sdk-pluginand install the Capacitor plugin as described in Installation. - 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. -
Import the plugin instead of using the
SNSMobileSDKglobal.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:
| Field | Type | Description |
|---|---|---|
success | Boolean | Boolean 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. |
status | String | SDK status. |
errorType | String | Formal reason of the error, if any. |
errorMsg | String | Verbose 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:
| Case | Description |
|---|---|
Ready | SDK is initialized and ready to be presented. |
Failed | SDK fails for some reasons (see errorType and errorMsg for details). |
Initial | No verification steps have been passed yet. |
Incomplete | Some but not all of the verification steps have been passed over. |
Pending | Verification is pending. |
TemporarilyDeclined | Applicant has been declined temporarily. |
FinallyRejected | Applicant has been finally rejected. |
Approved | Applicant has been approved. |
Error type
Here are the possible error types:
| Case | Description |
|---|---|
Unknown | Unknown or no fail. |
InvalidParameters | Attempt to set up with invalid parameters. |
Unauthorized | Unauthorized access detected (most likely accessToken is invalid or expired and has failed to be refreshed). |
InitialLoadingFailed | Initial loading from the backend has failed. |
ApplicantNotFound | No applicant is found for the given parameters. |
ApplicantMisconfigured | Applicant is found but is misconfigured (most likely lacks of idDocs). |
InitializationError | Initialization error occurred. |
NetworkError | Network error occurred (the user will be presented with the Network Oops screen). |
UnexpectedError | Some unexpected error occurred (the user will be presented with the Fatal Oops screen). |
Event
An object that represents an event happening along the processing:
| Field | Type | Description |
|---|---|---|
eventType | String | Event type. |
payload | Object | Event payload. |
Updated 54 minutes ago