# Cordova Plugin

# Installation

The plugin will ask for access to the camera and possibly the microphone too. Because of this, it is mandatory to have the corresponding usage descriptions in the application's Info.plist file. When the system prompts the user to allow access, the corresponding usage string is displayed as a part of the dialog box. In order to add the entries you must pass the variables CAMERA_USAGE and MICROPHONE_USAGE on plugin install.

cordova plugin add @sumsub/cordova-idensic-mobile-sdk-plugin \
	--variable CAMERA_USAGE="Let us take a photo" \
	--variable MICROPHONE_USAGE="Time to record a video"

If you do not provide the variables, the defaults shown in the example above will be used instead.

# Launching SDK

Before launching make sure you did the Backend routines

let apiUrl = 'https://test-api.sumsub.com'
// generate one on the backend
let accessToken = '_act-d0829687-f53a-45cb-b442-50a9da8f0550'
let snsMobileSDK = SNSMobileSDK.Builder(apiUrl)
        .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 '_act-5f8f4104-074e-45fd-949a-dd68e2bd986a'
          })
        })
        .build();
snsMobileSDK.launch().then(result => {
  console.log("SumSub SDK State: " + JSON.stringify(result))
}).catch(err => {
  console.log("SumSub SDK Error: " + JSON.stringify(err))
});```
Last Updated: 6/16/2020, 10:27:02 PM