Getting started
Requirements
iOS
Deployment Target
: iOS 11.0 or later
Android
minSdkVersion
: 23 (Android 6.0 Marshmallow)targetSdkVersion
: 34 (Android 14.0 Upside-Down Cake)
Installation
Bare Workflow
-
Install
@tokenstreet/react-native-idnow-videoident
:yarn add @tokenstreet/react-native-idnow-videoident --tilde
or
npm install @tokenstreet/react-native-idnow-videoident --save-exact
versioningWe do not follow Semantic Versioning 2.0.0 until
v1
is landed. Breaking changes in minor updates are possible. Therefore, it is recommended to install this package with a locked minor version.
iOS
-
Install the iOS dependencies:
pod install
-
Add the following properties to your
Info.plist
:<key>NSMicrophoneUsageDescription</key>
<string>Allow microphone access for video identification</string>
<key>NSCameraUsageDescription</key>
<string>Allow camera access for video identification</string>
Android
-
Add the IDnow maven url to your top-level
build.gradle
:allprojects {
repositories {
...
jcenter() {
// JCenter is now read-only. Therefore, no new versions are published there any more.
// We only fetch the necessary dependencies for IDnow from JCenter to avoid loading old dependencies.
content {
includeModule("me.relex", "circleindicator")
includeModule("com.github.barteksc", "android-pdf-viewer")
}
}
maven() {
url "https://raw.githubusercontent.com/idnow/de.idnow.android/master"
content {
includeModule("de.idnow.sdk", "idnow-android-sdk")
includeModule("de.idnow.insights", "idnow-android-insights-sdk")
}
}
}
} -
Add the following permissions to your
AndroidManifest.xml
(click here for more details):<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> -
Unfortunately, it is not yet possible to customise the colours for Android via JavaScript. To edit them, please follow the official guide.
Expo
Please be aware that Expo support is experimental and not officially supported.
-
Install
@tokenstreet/react-native-idnow-videoident
:npx expo install @tokenstreet/react-native-idnow-videoident expo-build-properties
-
Open your
app.json
and update your plugins section (expo install
would not do it for you, due to expo install skips scoped packages #17918):{
"plugins": [
[
"@tokenstreet/react-native-idnow-videoident",
{
"android": {
"excludeDuplicateClasses": false
}
}
],
["expo-build-properties", { "android": { "minSdkVersion": 23 } }]
]
}All configuration options are explained below:
Name Type Default Value Description android.excludeDuplicateClasses boolean
false
The following classes appeared twice in our projects in connection with this SDK, and can be excluded with this option: bcprov-jdk15to18
,bcutil-jdk15to18
,pdfium-android
,android-pdf-viewer
.
iOS
-
Open your
app.json
and update theinfoPlist
to give your app the necessary permissions:{
"ios": {
"infoPlist": {
"NSCameraUsageDescription": "Allow camera access for video identification",
"NSMicrophoneUsageDescription": "Allow microphone access for video identification"
}
}
}
Android
-
Open your
app.json
and update thepermissions
to give your app the necessary permissions:{
"android": {
"permissions": [
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.INTERNET",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.CAMERA",
"android.permission.FLASHLIGHT",
"android.permission.MODIFY_AUDIO_SETTINGS",
"android.permission.RECORD_AUDIO",
"android.permission.BLUETOOTH",
"android.permission.BLUETOOTH_ADMIN"
]
}
}
Usage
startVideoIdent
is asynchronous. For a successful identification the resultCode
is returned directly. If the identification failed, an error is thrown with a resultCode
. Also, an optional errorMessage
can be included.
You have the possibility to integrate it with a try...catch
block, with Promises
or with callbacks:
try...catch
Promises
- Callbacks
import type { IIdentificationErrorResult } from '@tokenstreet/react-native-idnow-videoident';
import { IdnowManager } from '@tokenstreet/react-native-idnow-videoident';
try {
const { resultCode } = await IdnowManager.startVideoIdent({ transactionToken: 'YOUR_TRANSACTION_TOKEN' });
console.log(resultCode);
} catch (error) {
if (error !== null && typeof error === 'object' && 'resultCode' in error) {
const identificationError = error as IIdentificationErrorResult;
console.log(identificationError.resultCode);
console.log(identificationError.errorMessage);
}
}
import type { IIdentificationErrorResult } from '@tokenstreet/react-native-idnow-videoident';
import { IdnowManager } from '@tokenstreet/react-native-idnow-videoident';
IdnowManager.startVideoIdent({ transactionToken: 'YOUR_TRANSACTION_TOKEN' })
.then(({ resultCode }) => console.log(resultCode))
.catch((error) => {
if (error !== null && typeof error === 'object' && 'resultCode' in error) {
const identificationError = error as IIdentificationErrorResult;
console.log(identificationError.resultCode);
console.log(identificationError.errorMessage);
}
});
import { IdnowManager } from '@tokenstreet/react-native-idnow-videoident';
void IdnowManager.startVideoIdent(
{ transactionToken: 'YOUR_TRANSACTION_TOKEN' },
{
onSuccess: ({ resultCode }) => console.log(resultCode),
onError: ({ resultCode, errorMessage }) => console.log(`${resultCode}\n${errorMessage}`),
},
);
All configuration options are documented in the TypeScript interfaces and an example is also available.