Skip to content

LykkeCorp/react-native-onfido-sdk

 
 

Repository files navigation

react-native-onfido-sdk

iOS and Android wrapper for onfido-ios-sdk and onfido-android-sdk.

iOS Setup

If you're already using Cocoapods, add the following to your Podfile

pod 'react-native-onfido-sdk', path: '../node_modules/react-native-onfido-sdk'

Otherwise, setup Podfile according to react native documentation, so the Podfile will look like this:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '11.0'

target 'YourTargetName' do
    pod 'React', :path => '../node_modules/react-native', :subspecs => [
        'Core',
        'CxxBridge', # Include this for RN >= 0.47
        'DevSupport', # Include this to enable In-App Devmenu if RN >= 0.43
        'RCTText',
        'RCTNetwork',
        'RCTWebSocket', # Needed for debugging
        'RCTAnimation', # Needed for FlatList and animations running on native UI thread
        ]
    # Explicitly include Yoga if you are using RN >= 0.42.0
    pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
    pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
    pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
    pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

    pod 'react-native-onfido-sdk', path: '../node_modules/react-native-onfido-sdk'

end

Remember to replace YourTargetName with your actual target name.

Next, run pod install.

Because Onfido sdk is written in Swift, we also need to go to YourTargetName -> Build Settings and search for Always Embed Swift Standard Libraries and set it to YES.

Android Setup

  1. Link the library by running
react-native link
  1. Add
maven {
        url  "https://dl.bintray.com/onfido/maven"
}

into

allprojects {
    repositories {
        ...
        maven {
                url  "https://dl.bintray.com/onfido/maven"
        }
    }
}

in android/build.gradle

  1. Enable multidex by adding multiDexEnabled true in app/build.gradle:
android {
    ...
    defaultConfig {
        ...
        multiDexEnabled true
    }
}

Usage

First, import the module:

import RNOnfidoSdk from "react-native-onfido-sdk"

Then, launch the sdk by using the following method:

RNOnfidoSdk.startSDK(params, successCallback, errorCallback);, where:

params

  • token (string, onfido mobile sdk token) required
  • applicantId (string, applicant id that needs to come from your backend implementation after an applicant has been created) required
  • documentTypes (array)

By default, onfido-ios-sdk and onfido-android-sdk can only be used either with all document types, or with a single document type. We've added the possibility to specify exactly which document type checks your app might use. If documentTypes is undefined, the sdk will launch with default document types (Passport, Driver's licence, National Id, Residence permit). The following document types are defined to be used:

  • RNOnfidoSdk.DocumentTypePassport
  • RNOnfidoSdk.DocumentTypeDrivingLicence
  • RNOnfidoSdk.DocumentTypeNationalIdentityCard
  • RNOnfidoSdk.DocumentTypeResidencePermit

Example:

const params = {
  token: "test...",
  applicantId: "test",
  documentTypes: [
    RNOnfidoSdk.DocumentTypePassport,
    RNOnfidoSdk.DocumentTypeNationalIdentityCard
  ]
}

In this example we opt in only for passport and national id card checks.

successCallback

Example:

const successCallback = () => {
  ...
}

errorCallback

Example:

const errorCallback = (error) => {
  ...
}

Publish on feedz

Before uploading, searching or installing packages on each machine, you will need to authenticate using a personal access token, as explained thoroughly in this guide

To publish a new package:

updade package version in package.json

create the package with npm pack --> react-native-onfido-sdk-0.0.x.tgz

publish the package on Lykke private register npm publish react-native-onfido-sdk-0.0.x.tgz --scope lykkecorp

In alternative to steps 2 & 3 just run sh buildPackage.sh from terminal

License

react-native-onfido-sdk is available under the MIT license. See the LICENCE file for more info.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Objective-C 55.2%
  • Java 20.5%
  • JavaScript 15.3%
  • Ruby 4.4%
  • Starlark 4.2%
  • Shell 0.4%