Skip to content

Cordova

The Cordova plugin has been completely reworked in release 8.4, resulting in changes to the public interfaces. This section provides a side-by-side comparison of the basic features between releases 8.3 and 8.4

Plugin Installation

The plugin's name has been changed. The previous plugin version is deprecated and will be supported for one more release (8.5), so it's strongly recommended to migrate to the new plugin version.

cordova plugin add @regulaforensics/document-reader
cordova plugin add @regulaforensics/document-reader-core-fullauthrfid
cordova plugin add @regulaforensics/cordova-plugin-document-reader-api
cordova plugin add @regulaforensics/cordova-plugin-document-reader-core-fullauthrfid

Accessing DocumentReader

var DocumentReader = DocumentReaderPlugin.DocumentReader
DocumentReader.instance.

var documentReader = DocumentReader.instance
documentReader.
var DocumentReader = DocumentReaderPlugin.DocumentReader

DocumentReader.

Preparing Database

await documentReader.prepareDatabase("Full", showProgress)

onDatabasePrepared()
DocumentReader.prepareDatabase("Full", (message) => {
    if (message != "database prepared")
        console.log("Downloading database: " + message + "%")
    else {
        console.log("DB prepared")
        onDatabasePrepared()
    }
}, e => { })

Initialization

var [success, error] = await documentReader.initialize(new InitConfig(license))

if (success) console.log("Init complete")
else console.log(error.code + ": " + error.message)
var config = new DocReaderConfig()
config.license = license
config.delayedNNLoad = true

DocumentReader.initializeReader(config, (message) => {
    result = JSON.parse(message)
    if (!result.success) {
        console.log("Init error: " + result.error.message)
    } else {
        console.log("Init complete")
    }
}, e => { })

Accessing Fields

var tag = documentReader.tag
documentReader.tag = "new tag"
DocumentReader.getTag((value) => {
    console.log("Tag: " + value)
}, e => { })

DocumentReader.setTag(value, (m) => {
    console.log("Tag set: " + value)
}, e => { })

Accessing Available Scenarios

var scenarios = documentReader.availableScenarios
DocumentReader.getAvailableScenarios((scenariosString) => {
    var scenariosJson = JSON.parse(scenariosString)
    var scenarios = []

    for (var index in scenariosJson) {
        var scenarioJson = scenariosJson[index]
        var scenario = DocumentReaderScenario.fromJson(typeof scenarioJson === "string" ? JSON.parse(scenarioJson) : scenarioJson)
        scenarios.add(scenario)
    }
}, e => { })

Changing Configuration

documentReader.functionality.showCaptureButton = true
var functionality = new Functionality()
functionality.showCaptureButton = true
DocumentReader.setFunctionality(functionality, e => { }, e => { })

Scanning Document

documentReader.startScanner(
    ScannerConfig.withScenario(Scenario.MRZ),
    handleCompletion,
)
var config = new ScannerConfig()
config.scenario = Enum.ScenarioIdentifier.SCENARIO_MRZ
DocumentReader.startScanner(config, (m) => {
    handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m)))
}, e => { })

Reading RFID

documentReader.rfid(new RFIDConfig(handleCompletion))
DocumentReader.startRFIDReader(false, false, false, (m) => { 
    var id = "rfidOnProgressCompletion"
    if (raw.substring(0, id.length) === id) {
        raw = raw.substring(id.length, raw.length)
        var notification = DocumentReaderNotification.fromJson(JSON.parse(raw))
    } else
        handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(raw)))    
}, e => { })