README
Getting started
Step into your app folder
> cd [your project's name]
and install the library from BioCatch's private repository:
> npm install <https://<GITHUB_USER>:<GITHUB_PASSWORD>@github.com/biocatchltd/react-native-biocatch.git#<TAG_VERSION>
or with yarn:
> yarn add <https://<GITHUB_USER>:<GITHUB_PASSWORD>@github.com/biocatchltd/react-native-biocatch.git#<TAG_VERSION>
Contact your dedicated solution engineer to get the details for a correct installation.
iOS
This integration revolves around using the CocoaPods dependency manager.
Therefore, before continuing with the installation, please make sure you have CocoaPods installed.
> sudo gem install cocoapods
Prior to linking the library, got to your project's ios/ folder and make sure a Podfile is present. If not, create one by running:
> pod init
Setting up cocoapods with BioCatch JFrog artifactor
In order to use CocoaPods with Artifactory, you will need to install the 'cocoapods-art' plugin.
To install cocoapods-art run the following command:
> gem install cocoapods-art
repo-art uses authentication as specified in your standard netrc file:
machine biocatchdev.jfrog.io
login <USERNAME>
password <PASSWORD>
Contact your dedicated solution engineer to get the required credentials
To add an Artifactory Specs repo:
> pod repo-art add biocatch-cocoapods-release "https://biocatchdev.jfrog.io/biocatchdev/api/pods/cocoapods-release"
To resolve pods from an Artifactory specs repo that you added, you must add the following to your Podfile:
plugin 'cocoapods-art', :sources => [
'biocatch-cocoapods-release'
]
Linking
Link the library by running:
> react-native link react-native-biocatch
Sometimes is required to sync the dependencies of the project, run the next command:
> yarn install
Install the dependencies by running:
> pod install
Open the generated ios/MyApp.xcworkspace with Xcode, set the Always Embed Swift Standard Libraries to Yes in the Build Settings of the root project.
For older versions of React Native, you must choose the "Legacy Build System" Build System option in Xcode's "File" -> "Project Settings"
Using a specific SDK version
If you want to use older or other specific versions of the BioCatchSDK, you can do so by specifying the version in your app's Podfile.
Add the following line to the Cocoapods under the 'target'
pod 'BioCatchSDK', "2.x.x.x"
Please consult your SD to get the latest version
Android
Setting gradle with BioCatch JFrog artifactor
In order to resolve the BioCatch SDK dependency, you need to add the Artifactory with your credentials as a repository to your root project's build.gradle file:
...
allprojects {
repositories {
// ... other repos
maven {
url "https://biocatchdev.jfrog.io/biocatchdev/libs-release"
// Your credentials here
// Please consult your SD to get the credentials
credentials {
username = "USERNAME"
password = "PASSWORD"
}
}
}
}...
Linking
Link the library by running:
> react-native link react-native-biocatch
Sometimes is required to sync the dependencies of the project, run the next command:
> yarn install
Using a specific SDK version
If you want to use older or other versions of the BioCatchSDK, you can do so by overriding the version in your app's module build.gradle file like this: Add the following line to the dependencies:
// Please consult your SD to get the latest version
debugImplementation "androidsdk:sdk-debug:2.x.x.x"
releaseImplementation "androidsdk:sdk-release:2.x.x.x"
Please consult your dedicated SE for the latest Android version.
The full code should look like the following:
Usage
Import or require the module:
import BioCatchPlugin from 'react-native-biocatch';
Available methods
start
Call the start function once during your app’s initialization to initialize BioCatch and start user data collection.
...
try {
let wupUrl = "YOUR_SERVER_HOST";
let cid = "YOUR_CUSTOMER_ID"
let csid = generateCSID();
BioCatchPlugin.start(wupUrl, cid, csid, false);
} catch (error) {
console.log(`error: ${error}`);
}
...
stop
BioCatch stops and is cleared from memory when the application is terminated, so it is not mandatory to call the stop function.
try {
await BioCatchPlugin.stop();
} catch (error) {
console.log(`error: ${error}`);
}
pause
Call pause to temporarily suspend BioCatch data collection. You may want to do this while the user is performing irrelevant activities to temporarily avoid using system resources for collecting and sending data. After calling pause, call resume to resume BioCatch data collection.
try {
await BioCatchPlugin.pause();
} catch (error) {
console.log(`error: ${error}`);
}
resume
Call resume to restart BioCatch data collection after calling pause.
try {
await BioCatchPlugin.resume();
} catch (error) {
console.log(`error: ${error}`);
}
changeContext
BioCatch JavaScript records a user journey as they navigate within an application. This data helps the BioCatch team find behavioral trends. To this end, the customer must define a context for each page or screen within the application based on the context types defined below. Using a predefined context will allow BioCatch to provide better scoring.
The customer application should call changeContext() each time the user enters a new page or screen. The context value is saved together with the rest of the user data.
try {
await BioCatchPlugin.changeContext("LOGIN")
} catch (error) {
console.log(`error: ${error}`);
}
updateCustomerSessionID
Your app must call this function every time the customerSessionID (the session identifier maintained by the customer app) changes. This lets BioCatch maintain a current mapping between its own internal session numbers and the customerSessionID.
try {
let newCsid = generateCSID();
await BioCatchPlugin.updateCustomerSessionID(newCsid);
} catch (error) {
console.log(`error: ${error}`);
}