iOS and Android wrapper for onfido-ios-sdk and onfido-android-sdk.
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.
- Link the library by running
react-native link
- Add
maven {
url "https://dl.bintray.com/onfido/maven"
}
into
allprojects {
repositories {
...
maven {
url "https://dl.bintray.com/onfido/maven"
}
}
}
in android/build.gradle
- Enable multidex by adding
multiDexEnabled true
in app/build.gradle:
android {
...
defaultConfig {
...
multiDexEnabled true
}
}
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) => {
...
}
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
react-native-onfido-sdk
is available under the MIT license. See the LICENCE file for more info.