import { NativeModules, DeviceEventEmitter } from"react-native";
let MobbscanAPI = NativeModules.MobbscanAPI;
//Init api and cleans plugin data
MobbscanAPI.initAPI("YOUR_LICENSE_HERE", data => {}, error => {});
//Sets api base url
MobbscanAPI.setBaseUrl("YOUR_MOBBSCAN_INSTANCE");
/* Starts scan
The document type is a String with all supported documents by MobbScan. For example: "ESPIDCard"
*/
MobbscanAPI.startScan(
DOCUMENT_TYPE,
OPERATION_MODE,
(result, scanId) => {},
error => {}
);
DeviceEventEmitter.addListener("SUCCESS_DETECTED_EVENT", data => {
var imageDetectedBase64 = data.IMAGE_DETECTED;
});
DeviceEventEmitter.addListener("ERROR_DETECTED_EVENT", () => {});
DeviceEventEmitter.addListener("SUCCESS_SCAN_EVENT", data => {
var result = data.RESULT;
var idDocument = data.ID_DOCUMENT;
var documentImageFace = data.DOCUMENT_IMAGE_FACE;
});
DeviceEventEmitter.addListener("ERROR_SCAN_EVENT", error => {});
DeviceEventEmitter.addListener("SUCCESS_DETECT_FACE_EVENT", data => {
var imageUserFace = data.USER_IMAGE_FACE;
});
DeviceEventEmitter.addListener("ERROR_DETECT_FACE_EVENT", error => {});
DeviceEventEmitter.addListener("SUCCESS_MATCH_EVENT", data => {
var score = data.SCORE;
});
DeviceEventEmitter.addListener("ERROR_MATCH_EVENT", error => {});
//Scan document side, it could be 'FRONT' or 'BACK'
MobbscanAPI.scanDocumentSide("FRONT");
/*
If you want detect face and get the matching score compared with the face of the document you can call to detectFace method.
It receives the mode, it could be: "DEFAULT", "LIVENESS_SMILE" and "LIVENESS_HEAD_MOVEMENT"
*/
MobbscanAPI.detectFace("LIVENESS_SMILE");