A unique access token should be created upon each SDK entry. In order to generate an access token, please refer to Valify's Authentication Documentation.
Importing
Import the module’s function in App.js/App.tsx file using the following line
Initialize the required parameters as follows while adding the desired configurations
constlanguage="<insert_language>"; // "en" is set as defaultconstdocument_verification= <boolean>; // false is set as defaultconst collect_user_info = <boolean>; // false is set as defaultconst document_verification_plus = <boolean>; // false is set as defaultconst advanced_confidence = <boolean>; // false is set as defaultconst profession_analysis = <boolean>; // false is set as defaultconst review_data = <boolean>; // default is trueconst preview_captured_image = <boolean>; //default is falseconst manual_capture_mode = <boolean>; //default is falseconst capture_only_mode = <boolean>; // default is falseconst primaryColor = ”<hex_color_code>”;const headers = {}; // default is emptyconst enable_logging= <boolean>; // default false
Configurations Breakdown
This section shows the breakdown of all optional builder configurations.
The following line is where the user interface language is set.
constlanguage="<insert_language>"; // ["ar" or "en"]
The currently supported languages are Arabic and English
If the following line is set to true, the SDK will return document verification plus data
constdocument_verification_plus= <boolean>;
If the following line is set to true, the SDK will return advanced confidence data
constadvanced_confidence= <boolean>;
If the following line is set to true, the captured image will be displayed for the user.
const preview_captured_image =<boolean>;
If the following line is set to true, the SDK will automatically enable manual capture if it detects that the user is unable to autocapture card.
const manual_capture_mode =<boolean>;
If the following line is set to true, a screen is added to the user flow that displays the images captured and the OCR result to the user.
constreview_data= <boolean>;
If the following line is set to true, the SDK purely performs image capturing and only returns these images in the SDK response.
constcapture_only_mode= <boolean>;
The following line is optional and can be used to receive event logs from the SDK experience to be used for user behavior analysis.
constenable_logging= <boolean>;
The following line is optional and can be used to set your company's branding color to the SDK's user interface.
constprimaryColor= ”<hex_color_code>”;
The following line is optional and can be used to set any headers that may be required for purposes specific to your application. Any headers set will be sent along with each API call made by the SDK.
constheaders= {};
Parameter Declaration
Declare the SDK parameters with the configuration variables previously created
exportdefaultfunctionApp() {startOCR(params).then(function (value) {console.log(value);consts=value.toString();constjson=JSON.parse(s);if(json.nameValuePairs.state =="SUCCESS"){ //an example code for using the response of the SDK , front will have the base64 image captured front side of the National ID during the successfull OCR process.
final front =nameValuePairs.ocrResult.ocrResult.frontNid;alert("success"); }elseif(json.nameValuePairs.state =="ERROR")alert("error");elseif(json.nameValuePairs.state =="FAILURE")alert("failure");elsealert("exit"); },function (error) {alert(error); } ); }