# Cordova Plugin

The Cordova Plugin initialization much depends on the mode your dashboard operates on. Use the documention below only if your dashbord is still in Flows/Levels mode, otherwise please refer to the main documentation.

# Backend routines

In order to embed our MobileSDK you have to complete a couple of preparation steps on your backend and use the results to pass into the MobileSDK initialization:

# Step 1: Applicant Flow

Set up your applicant flow or pick a predefined one (e.g. msdk-basic-kyc) in the dashboard

# Step 2: Access Token

Generate an access token that is associated with the externalUserId - a user id in your system. This is needed for constraining the access token to only one applicant.

curl -X POST \
  'https://test-api.sumsub.com/resources/accessTokens?userId=SomeUserIdInYourSystem&ttlInSecs=600' \
    -H 'Accept: application/json'

# Step 3: All done!

Now you can initialize the Mobile SDK.

# Launch

# Regular Flow

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 new Promise((resolve, reject) => {
        resolve('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)
  .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))
});

The snsMobileSDK.launch() returns a Promise that will be resolved with a Result object. Use it to determine the SDK status upon its closure.

Here is an example of the result:

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

Please find a detailed description in the main documentation.

# Action Flow

In order to run the SDK in applicant action mode, you need to create an applicant flow of Applicant actions type in the dashboard and specify its name as the flowName initialization parameter. Also, it'll be required to make an Access Token not only with the userId parameter, but with the externalActionId one as well.

Aside from the notes above, you manage the sdk the same way that you do with regular flows, the only difference is in how you get the action's result (please see the main documentation for further details).

Last Updated: 9/28/2021, 3:33:55 PM