# React Native
Version 1.31.2
# Preparing to work with plugins
To use any of our plugins, you must first obtain an accessToken.
- In the IDnGO Dashboard, generate an
appTokenandsecretKey. - Use them to make an API request to obtain an
accessToken.
Detailed instructions - Use the obtained token when initializing the SDK.
# Installation
- Create a
.npmrcfile in the root of the project and specify the repository URL for packages in it:
@idngo:registry=https://maven.cyberity.ru/repository/npm-group/
- In the command line, run:
yarn add @idngo/mobilesdk-react-native-module
The dependency will be automatically added to package.json:
"dependencies": {
"@idngo/mobilesdk-react-native-module": "1.31.2",
- Add dependencies on our MobileSDK to the iOS and Android parts of the application:
# Android
- API level 23 (Android 5.0) or newer
- Kotlin 1.9.25 or newer
Add the repository to android/build.gradle:
allprojects {
repositories {
// ...
maven { url "https://maven.cyberity.ru/repository/maven-public/" }
// ...
}
}
# iOS
Warning:
Make sure Bitcode is disabled in your project.
- Add the following to the top of
ios/Podfile:
platform :ios, '13.0'
source 'https://cdn.cocoapods.org/'
source 'https://github.com/idngo/specs.git'
- After installing the package, run the command:
npx pod-install
Tip:
If you encounter a compatibility error like «CocoaPods could not find compatible versions for pod "CyberityMobileSDK"», run:
cd ios && pod update CyberityMobileSDK && cd ..
# Hardware feature access
The framework will request access to the camera and microphone, photo gallery, and geolocation. Therefore, you must have corresponding usage descriptions in the application's Info.plist file. The description texts can be changed according to your requirements.
plutil -insert "NSCameraUsageDescription" -string "Grant camera access for taking photos" ios/${PWD##*/}/Info.plist
plutil -insert "NSMicrophoneUsageDescription" -string "Grant microphone access for recording video with sound" ios/${PWD##*/}/Info.plist
plutil -insert "NSPhotoLibraryUsageDescription" -string "Grant gallery access for selecting photos" ios/${PWD##*/}/Info.plist
plutil -insert "NSLocationWhenInUseUsageDescription" -string "Grant access to your location" ios/${PWD##*/}/Info.plist
# Initialization
# Configuration
Import the class in your application code:
import CBRMobileSDKBuilder from '@idngo/mobilesdk-react-native-module/src';
let launchCBRMobileSDK = () => {
// Before launching, ensure the verification level is configured and an accessToken has been obtained for the correct environment
let accessToken = "your_access_token";
let cbrMobileSDK = CBRMobileSDKBuilder.init(accessToken, () => {
// Called when the token expires
// Obtain a new accessToken from your backend
// Example implementation
return fetch('http://example.org/', { method: 'GET' })
.then(resp => { return 'your_new_access_token'})
})
// Optional handler for receiving event notifications
.withHandlers({
onStatusChanged: (event) => {
console.log("onStatusChanged: [" + event.prevStatus + "] => [" + event.newStatus + "]");
},
onLog: (event) => {
console.log("onLog: [Idensic] " + event.message);
}
})
.withDebug(true)
.withLocale('en') // Optional callback to set a different system language
.build();
cbrMobileSDK.launch()
.then(result => { console.log("SDK State: " + JSON.stringify(result))})
.catch(err => { console.log("SDK Error: " + JSON.stringify(err))});
}
The cbrMobileSDK.launch() method returns a Promise of a Result object, which contains the SDK status when it closes.
Result Object
An object describing the result of the last SDK launch:
| Field | Type | Description |
|---|---|---|
success | Boolean | TRUE — no errors, FALSE — an error occurred. |
status | String | SDK status. |
errorType | String | Error type. |
errorMsg | String | Detailed error description. |
{
"success": false,
"status": "Failed",
"errorType": "Unauthorized",
"errorMsg": "Unauthorized access with accessToken=[your_access_token]"
}
# Launching the SDK
You can then use launchCBRMobileSDK() to start the SDK.
<Button onPress={launchCBRMobileSDK} title="Launch SDK" />
# Closing the SDK
By default, once the user is approved, the SDK automatically closes after 3 seconds. You can adjust this time interval or disable automatic closing by setting it to 0:
cbrMobileSDK.withAutoCloseOnApprove(0)
To close the SDK programmatically, use:
cbrMobileSDK.dismiss()
# Additional settings
# User data
If necessary, you can pass an email and/or phone number that will be initially assigned to the user.
.withApplicantConf({
"email": "...",
"phone": "..."
})
# Preferred documents
For IDENTITY* steps (document verification), you can specify the country and document type that will be automatically selected, bypassing the document type selection screen.
Please note that the passed parameters will only be applied if the corresponding combination of country and document type (idDocType) is allowed at that step according to the level settings.
.withPreferredDocumentDefinitions({
"IDENTITY": {
"idDocType":"PASSPORT",
"country":"RUS"
},
"IDENTITY2": {
"idDocType":"DRIVERS",
"country":"ENG"
}
})
# Localization
You can customize the texts used in the SDK in the «SDK Integrations» section of the Dashboard.
The text language will be set according to the system settings, but you can change it to your desired language.
To override the system language:
.withLocale("en")
# Text strings
Part of the text can be set locally and persist when the SDK language settings change. For example, for situations where the translation server is unavailable due to lack of internet, but you need to guarantee that certain text is displayed, local string management is used.
.withStrings({
"sns_oops_network_title": "Oops! Seems like the network is down.",
"sns_oops_network_html": "Please check your internet connection and try again.",
"sns_oops_action_retry": "Try again"
})
# Analytics
The SDK collects and sends usage data to IDnGO servers. We do not track sensitive data; only general usage statistics are sent. This includes screen navigation, interaction with UI elements, and so on.
We analyze this data to improve IDnGO. The data is not shared with third parties and is not used for advertising.
To disable data analytics, use:
.withAnalyticsEnabled(false)
# Events
SDK events can be received via onEvent:
.withHandlers({
onEvent: (event) => {
console.log("onEvent: " + JSON.stringify(event));
}
})
Each event contains an eventType and a set of parameters packed into a payload dictionary.
{
"eventType": "StepInitiated",
"payload": {
"idDocSetType": "IDENTITY"
}
}
eventType Field Values
| Event Type | Payload | Description |
|---|---|---|
ApplicantLoaded | { | The user's application has been loaded. |
StepInitiated | { | Verification step initiated. |
StepCompleted | { | Verification step completed or cancelled. |
Analytics | { | An analytics event occurred. |
# Applicant actions
To use the SDK in applicant action mode, you need to create a verification level with the «Applicant Action» verification step (see more).
The access token is created with the userId, levelName, and externalActionId parameters.
# API Reference
# SDK Statuses
| Status | Description |
|---|---|
Ready | SDK is initialized and ready to launch. |
Failed | SDK terminated with an error. |
Initial | No verification steps have been completed yet. |
Incomplete | Part of the verification steps have been completed. |
Pending | Awaiting user verification. |
TemporarilyDeclined | Temporary rejection. |
FinallyRejected | Final rejection. |
Approved | The user's application has been approved. |
# Error Types errorType
| Error | Description |
|---|---|
Unknown | Unknown error. |
InvalidParameters | Invalid parameters. |
Unauthorized | Unauthorized access (invalid or expired token). |
InitialLoadingFailed | Initial loading from the server failed. |
ApplicantNotFound | User application not found. |
ApplicantMisconfigured | User application found, but configuration is incorrect (e.g., missing idDocs). |
InitializationError | Initialization error. |
NetworkError | Network error (user sees the «Network Oops» screen). |
UnexpectedError | Unexpected error («Fatal Oops» screen). |