# React Native Module

# Latest Release

Version 1.13.1

# Installation

yarn add @sumsub/react-native-mobilesdk-module

# Android

Add the following repository to your android/build.gradle file:

allprojects {
  repositories {
      // ...
      maven { url  "https://maven.sumsub.com/repository/maven-public/" }
      // ...
  }
}

# iOS

  1. Add as follows at the top of ios/Podfile:
source 'https://cdn.cocoapods.org/'
source 'https://github.com/SumSubstance/Specs.git'

Then run:

npx pod-install

If it fails with CocoaPods could not find compatible versions for pod "IdensicMobileSDK" message then do as follows:

cd ios && pod update IdensicMobileSDK && cd ..
  1. Update Info.plist to have description for the camera, microphone and the photo library usage
plutil -insert "NSCameraUsageDescription" -string "Let us take a photo" ios/${PWD##*/}/Info.plist
plutil -insert "NSMicrophoneUsageDescription" -string "Time to record a video" ios/${PWD##*/}/Info.plist
plutil -insert "NSPhotoLibraryUsageDescription" -string "Let us pick a photo" ios/${PWD##*/}/Info.plist

# Launching

Before launching make sure you did the Backend routines

import SNSMobileSDK from '@sumsub/react-native-mobilesdk-module';

// ...

let launchSNSMobileSDK = () => {

    let apiUrl = "https://test-api.sumsub.com" // or https://api.sumsub.com
    let flowName = "msdk-basic-kyc" // or set up your own with the dashboard
    let accessToken = "your_access_token" // generate one on the backend

    let snsMobileSDK = SNSMobileSDK.Builder(apiUrl, flowName)
            .withAccessToken(accessToken, () => {
              // this is a token expiration handler, 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 fetch('http://example.org/', {
                method: 'GET',
              }).then(resp => {
                // return a fresh token from here
                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 + "]");
              },
              onLog: (event) => {
                console.log("onLog: [Idensic] " + event.message);
              }
            })            
            .withDebug(true)
            .withSupportEmail('[email protected]')
            .withLocale('en') // Optional, for cases when you need to override system locale
            .build();

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

  <Button
      onPress={launchSNSMobileSDK}
      title="Launch SumSub SDK"
  />

# Dismission

Normally the user closes the sdk himself, but if you need to do it programmatically, here is the helper:

snsMobileSDK.dismiss()

# Result

The result is the javascript object described the outcome of the last sdk launch, for example:

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

While successand status are always present, the rest fields are optional:

Field Type Description
success Boolean The boolean value indicates if there was an error on the moment the sdk is closed. Use errorType and errorMsg to see the reasons of the error if any
status String SDK status
errorType String A formal reason of the error if any
errorMsg String A verbose error description if any
actionResult Object Describes the result of the latest applicant action's invocation if any

# status

Here is 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 are 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
ActionCompleted Applicant action has been completed

# errorType

Here is the possible fail reasons:

Case Description
Unknown Unknown or no fail
InvalidParameters An attempt to setup with invalid parameters
Unauthorized Unauthorized access detected (most likely accessToken is invalid or expired and had failed to be refreshed)
InitialLoadingFailed Initial loading from backend is failed
ApplicantNotFound No applicant is found for the given parameters
ApplicantMisconfigured Applicant is found, but is misconfigured (most likely lacks of idDocs)
InititlizationError An initialization error occured
NetworkError A network error occured (the user will be presented with Network Oops screen)
UnexpectedError Some unexpected error occured (the user will be presented with Fatal Oops screen)

# actionResult

When an applicant action is completed the status will be set to ActionCompleted and the result structure would contain the actionResult field that describes the outcome of the last invocation:

{
  "success": true,
  "status": "ActionCompleted",
  "actionResult": {
    "actionId": "5f77648daee05c419400c572",
    "answer": "GREEN"
  }
}

An empty value of actionResult.answer means that the action was cancelled.

Field Type Description
actionId String Applicant action identifier to check the results against the server
answer String Overall result. Typical values are GREEN, RED or ERROR
Last Updated: 10/22/2020, 12:31:11 PM