React Native

Follow the below guide in order to get started with Incode Mobile Onboarding. We currently support NPM and Expo.

Requirements

React Native SDK Documentation

Getting Started

The React Native SDK is distributed through a private NPM package. Before installing you must become a member of our React Native team by contacting Incode and sharing your NPM user name. NPM accounts are free. You can sign-up here. After sharing your NPM username with Incode you will receive an email invitation (to the email address associated with your NPM account ) to join. You must accept this invitation to access the SDK. Invitations expire after 7 days.

Add a .npmrc file to your project

A .npmrc file is used to customize the behavior of NPM distributions. It is used to configure private package access. Within the root directory of your React Native project create a .npmrc file using the below code as a guide. Tokens can be obtained from NPM using these instructions.

//registry.npmjs.org/:_authToken=<your-npm-token>
//registry.npmjs.org/:username=<your-npm-username>
//registry.npmjs.org/:email=<your-email-assocated-with-your-npm-account>

Installation the React Native SDK

The Incode React Native SDK is distributed through a private NPM package.

npm i @incode-sdks/react-native-incode-sdk

Additional Setup for iOS

After installation, if you are using the React Native CLI as a build tool, it is necessary to do the linking for iOS, after running the command above.

Requirements:

  1. Change your Podfile so it equires deployment target 11 or higher.
-platform :ios, '10.0'
+platform :ios, '11.0'
  1. Add this line to the top of your Podfile:

RN >= 0.69: no changes needed

RN < 0.69:

 pod 'react-native-incode-sdk', :path => '../node_modules/@incode-sdks/react-native-incode-sdk/'
  1. Add an empty Swift file (e.g. Void.swift) through xCode to your native project. When prompted for a bridging header, choose Create Bridging header.

  2. Relying on React Native's auto-linking, run the following:

cd ios && pod install cd ..
  1. Adapt Info.plist by adding:
  • NSCameraUsageDescription. The SDK uses the camera in order to verify the identity of the customer, e.g. in ID scan, Selfie scan and so on.
  • NSLocationWhenInUseUsageDescription. The SDK uses the current user location in order to detect exact location for Geolocation step.
  • NSMicrophoneUsageDescription. The SDK uses microphone for performing a video call during Video Conference step or for doing speech recognition during Video Selfie.
  1. Add Linker flags

Go to your project's Target, Build Settings -> Other Linker Flags and add these flags:

$(inherited) -all_load -ObjC -l “stdc++” -l “iconv”

Additional setup for Android

If you are using the React Native CLI as a build tool, please make sure that following settings are set in your app's build.gradle file:

  1. Change your minSdkVersion to 21 or higher. Set compileSdkVersion to 33 or higher.

  2. Add this dependency in you app's build.gradle:

  dependencies {
+    implementation 'com.incode.sdk:core-light:2.6.2'
  }

  1. Application has multidex support enabled:
  defaultConfig {
    ...
+   multiDexEnabled true
    ...
  }
  dependencies {
    ...
+   implementation 'com.android.support:multidex:1.0.3'
    ...
  }

Your Application class should now be able to extend MultiDexApplication:


+  import androidx.multidex.MultiDexApplication;

+  public class MyApplication extends MultiDexApplication implements ReactApplication {
  ...
 }
  1. Modify your project's build.gradle so it contains Artifactory username and password, provided by Incode.
allprojects {
  repositories {
    ...
+    jcenter()
+    maven {
+      url "http://repo.incode.com/artifactory/libs-incode-welcome"
+      credentials {
+        username = "ARTIFACTORY_USERNAME"
+        password = "ARTIFACTORY_PASSWORD"
+      }
+    }
    ...
  }
}

Expo usage

If you are using Expo as a build tool you can Install the SDK using using the Expo CLI.

  1. Ensure you have a .npmrc configured to access our private React Native SDK.
//registry.npmjs.org/:_authToken=<your-npm-token>
//registry.npmjs.org/:username=<your-npm-username>
//registry.npmjs.org/:email=<your-email-assocated-with-your-npm-account>
  1. Install the React Native SDK
npx expo install @incode-sdks/react-native-incode-sdk
  1. Install configuration plugin
npx expo install @incode-sdks/expo-incode-sdk-configuration
  1. Integrate and configure configuration plugin. Update 'plugins' field in app.json file:
{
  "expo": {
      "plugins": [
          [
              "@incode-sdks/expo-incode-sdk-configuration",
              {
                  "artifactoryUserName": "client_artifactory_username",
                  "artifactoryPassword": "client_artifactory_password"
              }
          ]
      ]
  }
}