@regulaforensics/cordova-plugin-document-reader-api 6.9.1 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -40
- package/example/README.md +32 -0
- package/example/config.xml +5 -1
- package/example/package.json +7 -10
- package/example/www/js/index.js +85 -159
- package/package.json +1 -1
- package/plugin.xml +8 -8
- package/src/android/BluetoothUtil.kt +78 -74
- package/src/android/Config.kt +692 -0
- package/src/android/DocumentReader.kt +524 -0
- package/src/android/JSONConstructor.kt +2198 -0
- package/src/android/Utils.kt +261 -0
- package/src/android/build.gradle +3 -3
- package/src/ios/RGLWConfig.h +48 -0
- package/src/ios/RGLWConfig.m +1312 -0
- package/src/ios/RGLWDocumentReader.h +14 -11
- package/src/ios/RGLWDocumentReader.m +384 -579
- package/src/ios/RGLWJSONConstructor.h +173 -69
- package/src/ios/RGLWJSONConstructor.m +1832 -786
- package/www/DocumentReader.js +869 -278
- package/src/android/DocumentReader.java +0 -1118
- package/src/android/Helpers.java +0 -259
- package/src/android/JSONConstructor.java +0 -1119
- package/src/android/RegulaConfig.java +0 -830
- package/src/ios/RGLWRegulaConfig.h +0 -26
- package/src/ios/RGLWRegulaConfig.m +0 -1152
package/README.md
CHANGED
|
@@ -1,49 +1,19 @@
|
|
|
1
|
-
# Regula Document Reader
|
|
1
|
+
# Regula Document Reader SDK for Cordova
|
|
2
|
+
|
|
2
3
|
Regula Document Reader SDK allows you to read various kinds of identification documents, passports, driving licenses, ID cards, etc. All processing is performed completely _**offline**_ on your device. No any data leaving your device.
|
|
3
4
|
|
|
4
5
|
You can use native camera to scan the documents or image from gallery for extract all data from it.
|
|
5
6
|
|
|
6
7
|
This repository contains the source code of the Document Reader API, and the sample application that demonstrates the _**API**_ calls you can use to interact with the Document Reader library.
|
|
7
8
|
|
|
8
|
-
# Contents
|
|
9
|
-
* [How to build demo application](#how-to-build-demo-application)
|
|
10
|
-
* [Troubleshooting license issues](#troubleshooting-license-issues)
|
|
11
|
-
* [Documentation](#documentation)
|
|
12
|
-
* [Additional information](#additional-information)
|
|
13
|
-
|
|
14
|
-
## How to build the demo application
|
|
15
|
-
1. Visit [client.regulaforensics.com](https://client.regulaforensics.com) to get a trial license (`regula.license` file). The license creation wizard will guide you through the necessary steps.
|
|
16
|
-
2. Download or clone current repository using the command `git clone https://github.com/regulaforensics/DocumentReader-Cordova-Plugin.git`.
|
|
17
|
-
3. Run the following commands in Terminal:
|
|
18
|
-
```bash
|
|
19
|
-
$ cd example
|
|
20
|
-
$ npm install
|
|
21
|
-
$ npx jetify
|
|
22
|
-
$ cordova prepare
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
4. Copy the `regula.license` file to the `example/www` folder.
|
|
26
|
-
6. Android:
|
|
27
|
-
* Run `cordova run android` inside `example` folder - this is just one way to run the app. You can also run it directly from within Android Studio.
|
|
28
|
-
|
|
29
|
-
**Note**: if the gallery doesn't open, check if the following line is presented in the AndroidManifest.xml inside the `application` tag:
|
|
30
|
-
`<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@android:style/Theme.Holo.Light" />`
|
|
31
|
-
|
|
32
|
-
7. iOS:
|
|
33
|
-
* Run `cordova run ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
34
|
-
|
|
35
|
-
### Troubleshooting license issues
|
|
36
|
-
If you have issues with license verification when running the application, please verify that next is true:
|
|
37
|
-
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
|
|
38
|
-
3. The license is valid (not expired).
|
|
39
|
-
4. The date and time on the device, where you run the application, are valid.
|
|
40
|
-
5. You use the latest release version of the Document Reader SDK.
|
|
41
|
-
6. You placed the `license` into the correct folder as described [here](#how-to-build-demo-application).
|
|
42
|
-
|
|
43
9
|
## Documentation
|
|
44
|
-
You can find documentation on API [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/cordova).
|
|
45
10
|
|
|
46
|
-
|
|
47
|
-
|
|
11
|
+
You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/cordova).
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
To obtaining the production license or other purchasing information, please [submit an inquiry](https://regulaforensics.com/talk-to-an-expert) and our sales team will contact you shortly.
|
|
16
|
+
|
|
17
|
+
## Support
|
|
48
18
|
|
|
49
|
-
|
|
19
|
+
Please do not hesitate to [contact us](https://support.regulaforensics.com/hc/requests/new), if you need any assistance or want to report a bug / suggest an improvement.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# How to build the demo application
|
|
2
|
+
|
|
3
|
+
1. Get the trial license at [client.regulaforensics.com](https://client.regulaforensics.com/) (`regula.license` file). The license creation wizard will guide you through the necessary steps.
|
|
4
|
+
2. Get the trial database at [client.regulaforensics.com/customer/databases](https://client.regulaforensics.com/customer/databases) (`db.dat`)
|
|
5
|
+
3. Download or clone current repository using the command `git clone https://github.com/regulaforensics/DocumentReader-Cordova-Plugin.git`.
|
|
6
|
+
4. Copy the `regula.license` file to the `example/www/` folder.
|
|
7
|
+
5. Copy the `db.dat` file to the `example/www/` folder.
|
|
8
|
+
6. Run the following commands in Terminal:
|
|
9
|
+
```bash
|
|
10
|
+
$ cd example
|
|
11
|
+
$ npm install
|
|
12
|
+
$ npx jetify
|
|
13
|
+
$ cordova prepare
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
7. Android:
|
|
17
|
+
* Run `cordova run android` inside `example` folder - this is just one way to run the app. You can also run it directly from within Android Studio.
|
|
18
|
+
|
|
19
|
+
**Note**: if the gallery doesn't open, check if the following line is presented in the AndroidManifest.xml inside the `application` tag:
|
|
20
|
+
`<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@android:style/Theme.Holo.Light" />`
|
|
21
|
+
|
|
22
|
+
8. iOS:
|
|
23
|
+
* Run `cordova run ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
24
|
+
|
|
25
|
+
# Troubleshooting license issues
|
|
26
|
+
|
|
27
|
+
If you have issues with license verification when running the application, please verify that next is true:
|
|
28
|
+
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
|
|
29
|
+
3. The license is valid (not expired).
|
|
30
|
+
4. The date and time on the device, where you run the application, are valid.
|
|
31
|
+
5. You use the latest release version of the Document Reader SDK.
|
|
32
|
+
6. You placed the `license` into the correct folder as described [here](#how-to-build-demo-application).
|
package/example/config.xml
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<allow-intent href="mailto:*" />
|
|
17
17
|
<allow-intent href="geo:*" />
|
|
18
18
|
<platform name="android">
|
|
19
|
+
<resource-file src="www/db.dat" target="app/src/main/assets/Regula/db.dat"/>
|
|
19
20
|
<preference name="android-minSdkVersion" value="23" />
|
|
20
21
|
<preference name="android-targetSdkVersion" value="34" />
|
|
21
22
|
<allow-intent href="market:*" />
|
|
@@ -27,12 +28,15 @@
|
|
|
27
28
|
</config-file>
|
|
28
29
|
</platform>
|
|
29
30
|
<platform name="ios">
|
|
31
|
+
<resource-file src="www/db.dat" />
|
|
30
32
|
<allow-intent href="itms:*" />
|
|
31
33
|
<allow-intent href="itms-apps:*" />
|
|
32
|
-
<preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
|
|
33
34
|
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
|
|
34
35
|
<string>To use camera</string>
|
|
35
36
|
</config-file>
|
|
37
|
+
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
|
|
38
|
+
<string>To pick images</string>
|
|
39
|
+
</config-file>
|
|
36
40
|
<config-file target="*-Info.plist" parent="NFCReaderUsageDescription">
|
|
37
41
|
<string>To use NFC</string>
|
|
38
42
|
</config-file>
|
package/example/package.json
CHANGED
|
@@ -13,25 +13,22 @@
|
|
|
13
13
|
"author": "Regula Forensics Inc.",
|
|
14
14
|
"license": "commercial",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@regulaforensics/cordova-plugin-document-reader-api": "
|
|
17
|
-
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "
|
|
18
|
-
"cordova-android": "12.0.
|
|
19
|
-
"cordova-ios": "7.0.
|
|
16
|
+
"@regulaforensics/cordova-plugin-document-reader-api": "7.2.0",
|
|
17
|
+
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "7.2.0",
|
|
18
|
+
"cordova-android": "12.0.1",
|
|
19
|
+
"cordova-ios": "7.0.1",
|
|
20
20
|
"cordova-plugin-add-swift-support": "2.0.2",
|
|
21
21
|
"cordova-plugin-advanced-http": "3.3.1",
|
|
22
|
-
"cordova-plugin-
|
|
22
|
+
"cordova-plugin-camera": "7.0.0",
|
|
23
23
|
"cordova-plugin-file": "8.0.0",
|
|
24
24
|
"jetifier": "2.0.0"
|
|
25
25
|
},
|
|
26
26
|
"cordova": {
|
|
27
27
|
"plugins": {
|
|
28
|
-
"@regulaforensics/cordova-plugin-document-reader-api": {
|
|
29
|
-
"CAMERA_USAGE_DESCRIPTION": "To take photo",
|
|
30
|
-
"READ_EXTERNAL_STORAGE": "To choose photo"
|
|
31
|
-
},
|
|
28
|
+
"@regulaforensics/cordova-plugin-document-reader-api": {},
|
|
32
29
|
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": {},
|
|
33
30
|
"cordova-plugin-file": {},
|
|
34
|
-
"cordova-plugin-
|
|
31
|
+
"cordova-plugin-camera": {},
|
|
35
32
|
"cordova-plugin-advanced-http": {}
|
|
36
33
|
},
|
|
37
34
|
"platforms": [
|
package/example/www/js/index.js
CHANGED
|
@@ -4,6 +4,15 @@ var app = {
|
|
|
4
4
|
},
|
|
5
5
|
|
|
6
6
|
onDeviceReady: function () {
|
|
7
|
+
function onInitialized() {
|
|
8
|
+
document.getElementById("status").innerHTML = "Ready"
|
|
9
|
+
document.getElementById("status").style.backgroundColor = "green"
|
|
10
|
+
|
|
11
|
+
var functionality = new Functionality()
|
|
12
|
+
functionality.showCaptureButton = true
|
|
13
|
+
DocumentReader.setFunctionality(functionality, function (s) { }, function (e) { })
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
this.receivedEvent('deviceready')
|
|
8
17
|
document.getElementById("status").innerHTML = "loading......"
|
|
9
18
|
document.getElementById("status").style.backgroundColor = "grey"
|
|
@@ -12,10 +21,13 @@ var app = {
|
|
|
12
21
|
// This way you can import any class declared in DocumentReaderPlugin
|
|
13
22
|
var DocumentReader = DocumentReaderPlugin.DocumentReader
|
|
14
23
|
var DocumentReaderResults = DocumentReaderPlugin.DocumentReaderResults
|
|
24
|
+
var DocumentReaderNotification = DocumentReaderPlugin.DocumentReaderNotification
|
|
15
25
|
var DocumentReaderScenario = DocumentReaderPlugin.DocumentReaderScenario
|
|
16
26
|
var DocumentReaderCompletion = DocumentReaderPlugin.DocumentReaderCompletion
|
|
17
27
|
var ScannerConfig = DocumentReaderPlugin.ScannerConfig
|
|
18
28
|
var RecognizeConfig = DocumentReaderPlugin.RecognizeConfig
|
|
29
|
+
var DocReaderConfig = DocumentReaderPlugin.DocReaderConfig
|
|
30
|
+
var Functionality = DocumentReaderPlugin.Functionality
|
|
19
31
|
var Enum = DocumentReaderPlugin.Enum
|
|
20
32
|
|
|
21
33
|
var selectedScenario = "Mrz"
|
|
@@ -34,7 +46,7 @@ var app = {
|
|
|
34
46
|
document.getElementById("rfidUIHeader").style.color = rfidUIHeaderColor
|
|
35
47
|
document.getElementById("rfidDescription").innerHTML = rfidDescription
|
|
36
48
|
document.getElementById("rfidProgress").value = rfidProgress
|
|
37
|
-
document.getElementById("cancelButton").addEventListener("click",
|
|
49
|
+
document.getElementById("cancelButton").addEventListener("click", hideRfidUI)
|
|
38
50
|
|
|
39
51
|
function postInitialize(scenarios, canRfid) {
|
|
40
52
|
for (var index in scenarios) {
|
|
@@ -78,58 +90,42 @@ var app = {
|
|
|
78
90
|
}, function (e) { })
|
|
79
91
|
}
|
|
80
92
|
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
function recognize() {
|
|
94
|
+
navigator.camera.getPicture(function (result) {
|
|
95
|
+
document.getElementById("status").innerHTML = "processing image......"
|
|
96
|
+
document.getElementById("status").style.backgroundColor = "grey"
|
|
97
|
+
var config = new RecognizeConfig()
|
|
98
|
+
config.scenario = selectedScenario
|
|
99
|
+
config.image = result
|
|
100
|
+
DocumentReader.recognize(config, function (m) {
|
|
101
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m)))
|
|
102
|
+
}, function (e) { })
|
|
103
|
+
}, function (e) { }, {
|
|
104
|
+
destinationType: Camera.DestinationType.DATA_URL,
|
|
105
|
+
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
|
|
106
|
+
mediaType: Camera.MediaType.PICTURE
|
|
94
107
|
})
|
|
95
108
|
}
|
|
96
109
|
|
|
97
|
-
function
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
function handleCompletion(completion) {
|
|
111
|
+
if (isReadingRfidCustomUi) {
|
|
112
|
+
if (completion.action == Enum.DocReaderAction.ERROR) restartRfidUI()
|
|
113
|
+
if (actionSuccess(completion.action) || actionError(completion.action)) {
|
|
114
|
+
hideRfidUI()
|
|
115
|
+
displayResults(completion.results)
|
|
116
|
+
}
|
|
117
|
+
} else if (actionSuccess(completion.action) || actionError(completion.action))
|
|
118
|
+
handleResults(completion.results)
|
|
100
119
|
}
|
|
101
120
|
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
// document.getElementById("status").style.backgroundColor = "grey"
|
|
106
|
-
// var config = new RecognizeConfig()
|
|
107
|
-
// config.scenario = selectedScenario
|
|
108
|
-
// config.images = images
|
|
109
|
-
// DocumentReader.recognize(config, function (m) {
|
|
110
|
-
// handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m)))
|
|
111
|
-
// }, function (e) { })
|
|
112
|
-
// }, function (e) { }, { maximumImagesCount: 10, outputType: window.imagePicker.OutputType.BASE64_STRING })
|
|
121
|
+
function actionSuccess(action) {
|
|
122
|
+
if (action == Enum.DocReaderAction.COMPLETE || action == Enum.DocReaderAction.TIMEOUT) return true
|
|
123
|
+
return false
|
|
113
124
|
}
|
|
114
125
|
|
|
115
|
-
function
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
hideRfidUI()
|
|
119
|
-
if (isReadingRfidCustomUi && completion.action === Enum.DocReaderAction.NOTIFICATION)
|
|
120
|
-
updateRfidUI(completion.results.documentReaderNotification)
|
|
121
|
-
if (completion.action === Enum.DocReaderAction.COMPLETE)
|
|
122
|
-
if (isReadingRfidCustomUi)
|
|
123
|
-
if (completion.results.rfidResult !== 1)
|
|
124
|
-
restartRfidUI()
|
|
125
|
-
else {
|
|
126
|
-
hideRfidUI()
|
|
127
|
-
displayResults(completion.results)
|
|
128
|
-
}
|
|
129
|
-
else
|
|
130
|
-
handleResults(completion.results)
|
|
131
|
-
if (completion.action === Enum.DocReaderAction.TIMEOUT)
|
|
132
|
-
handleResults(completion.results)
|
|
126
|
+
function actionError(action) {
|
|
127
|
+
if (action == Enum.DocReaderAction.CANCEL || action == Enum.DocReaderAction.ERROR) return true
|
|
128
|
+
return false
|
|
133
129
|
}
|
|
134
130
|
|
|
135
131
|
function showRfidUI() {
|
|
@@ -141,70 +137,48 @@ var app = {
|
|
|
141
137
|
|
|
142
138
|
function hideRfidUI() {
|
|
143
139
|
// show animation
|
|
140
|
+
DocumentReader.stopRFIDReader(function (s) { }, function (e) { });
|
|
144
141
|
restartRfidUI()
|
|
145
142
|
isReadingRfidCustomUi = false
|
|
146
143
|
document.getElementById("rfidUI").style.display = isReadingRfidCustomUi ? "" : "none"
|
|
147
144
|
document.getElementById("mainUI").style.display = !isReadingRfidCustomUi ? "" : "none"
|
|
148
|
-
rfidUIHeader = "Reading RFID"
|
|
149
|
-
document.getElementById("rfidUIHeader").
|
|
150
|
-
rfidUIHeaderColor = "black"
|
|
151
|
-
document.getElementById("rfidUIHeader").style.color = rfidUIHeaderColor
|
|
145
|
+
document.getElementById("rfidUIHeader").innerHTML = "Reading RFID"
|
|
146
|
+
document.getElementById("rfidUIHeader").style.color = "black"
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
function restartRfidUI() {
|
|
155
|
-
|
|
156
|
-
document.getElementById("rfidUIHeader").
|
|
157
|
-
|
|
158
|
-
document.getElementById("
|
|
159
|
-
rfidDescription = "Place your phone on top of the NFC tag"
|
|
160
|
-
document.getElementById("rfidDescription").innerHTML = rfidDescription
|
|
161
|
-
rfidProgress = -1
|
|
162
|
-
document.getElementById("rfidProgress").value = rfidProgress
|
|
150
|
+
document.getElementById("rfidUIHeader").style.color = "red"
|
|
151
|
+
document.getElementById("rfidUIHeader").innerHTML = "Failed!"
|
|
152
|
+
document.getElementById("rfidDescription").innerHTML = "Place your phone on top of the NFC tag"
|
|
153
|
+
document.getElementById("rfidProgress").value = -1
|
|
163
154
|
}
|
|
164
155
|
|
|
165
|
-
function updateRfidUI(
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
rfidDescription = Enum.eRFID_DataFile_Type.getTranslation(results.dataFileType)
|
|
156
|
+
function updateRfidUI(notification) {
|
|
157
|
+
if (notification.notificationCode === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP) {
|
|
158
|
+
rfidDescription = "ERFIDDataFileType: " + notification.dataFileType
|
|
169
159
|
document.getElementById("rfidDescription").innerHTML = rfidDescription
|
|
170
160
|
}
|
|
171
|
-
rfidUIHeader = "Reading RFID"
|
|
172
|
-
document.getElementById("rfidUIHeader").
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
rfidProgress = results.progress
|
|
176
|
-
document.getElementById("rfidProgress").value = rfidProgress
|
|
177
|
-
if (window.cordova.platformId === 'ios')
|
|
178
|
-
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + results.progress + "%", function (e) { }, function (e) { })
|
|
161
|
+
document.getElementById("rfidUIHeader").innerHTML = "Reading RFID"
|
|
162
|
+
document.getElementById("rfidUIHeader").style.color = "black"
|
|
163
|
+
if (notification.progress != null)
|
|
164
|
+
document.getElementById("rfidProgress").value = notification.progress
|
|
179
165
|
}
|
|
180
166
|
|
|
181
167
|
function customRFID() {
|
|
182
168
|
showRfidUI()
|
|
183
|
-
DocumentReader.readRFID(function (m) { handleRfidCompletion(m) }, function (e) { })
|
|
169
|
+
DocumentReader.readRFID(false, false, false, function (m) { handleRfidCompletion(m) }, function (e) { })
|
|
184
170
|
}
|
|
185
171
|
|
|
186
172
|
function usualRFID() {
|
|
187
173
|
isReadingRfid = true
|
|
188
|
-
DocumentReader.startRFIDReader(function (m) { handleRfidCompletion(m) }, function (e) { })
|
|
174
|
+
DocumentReader.startRFIDReader(false, false, false, function (m) { handleRfidCompletion(m) }, function (e) { })
|
|
189
175
|
}
|
|
190
176
|
|
|
191
177
|
function handleRfidCompletion(raw) {
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
if (raw.substring(0, notification.length) === notification) {
|
|
197
|
-
raw = raw.substring(notification.length, raw.length)
|
|
198
|
-
console.log(notification + ": " + raw)
|
|
199
|
-
} else if (raw.substring(0, paCert.length) === paCert) {
|
|
200
|
-
raw = raw.substring(paCert.length, raw.length)
|
|
201
|
-
console.log(paCert + ": " + raw)
|
|
202
|
-
} else if (raw.substring(0, taCert.length) === taCert) {
|
|
203
|
-
raw = raw.substring(taCert.length, raw.length)
|
|
204
|
-
console.log(taCert + ": " + raw)
|
|
205
|
-
} else if (raw.substring(0, taSig.length) === taSig) {
|
|
206
|
-
raw = raw.substring(taSig.length, raw.length)
|
|
207
|
-
console.log(taSig + ": " + raw)
|
|
178
|
+
var id = "rfidOnProgressCompletion"
|
|
179
|
+
if (raw.substring(0, id.length) === id) {
|
|
180
|
+
raw = raw.substring(id.length, raw.length)
|
|
181
|
+
updateRfidUI(DocumentReaderNotification.fromJson(JSON.parse(raw)))
|
|
208
182
|
} else
|
|
209
183
|
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(raw)))
|
|
210
184
|
}
|
|
@@ -212,7 +186,7 @@ var app = {
|
|
|
212
186
|
function handleResults(results) {
|
|
213
187
|
clearResults()
|
|
214
188
|
if (doRfid && !isReadingRfid && results != null && results.chipPage != 0) {
|
|
215
|
-
//customRFID()
|
|
189
|
+
// customRFID()
|
|
216
190
|
usualRFID()
|
|
217
191
|
} else {
|
|
218
192
|
isReadingRfid = false
|
|
@@ -253,7 +227,6 @@ var app = {
|
|
|
253
227
|
DocumentReader.textFieldValueByType(results, Enum.eVisualFieldType.FT_SURNAME_AND_GIVEN_NAMES, function (value) {
|
|
254
228
|
document.getElementById("status").style.backgroundColor = "green"
|
|
255
229
|
document.getElementById("status").innerHTML = value
|
|
256
|
-
this.setState({ fullName: value })
|
|
257
230
|
}, function (error) { console.log(error) })
|
|
258
231
|
|
|
259
232
|
DocumentReader.graphicFieldImageByType(results, Enum.eGraphicFieldType.GF_DOCUMENT_IMAGE, function (value) {
|
|
@@ -273,33 +246,6 @@ var app = {
|
|
|
273
246
|
document.getElementById("portraitImage").src = "img/portrait.png"
|
|
274
247
|
}
|
|
275
248
|
|
|
276
|
-
function addCertificates() {
|
|
277
|
-
window.resolveLocalFileSystemURL(cordova.file.applicationDirectory + "www/certificates/", function (fileSystem) {
|
|
278
|
-
fileSystem.createReader().readEntries(function (entries) {
|
|
279
|
-
for (var i in entries) {
|
|
280
|
-
var item = entries[i]
|
|
281
|
-
if (item.isFile) {
|
|
282
|
-
var findExt = item.name.split('.')
|
|
283
|
-
var pkdResourceType = 0
|
|
284
|
-
if (findExt.length > 0)
|
|
285
|
-
pkdResourceType = Enum.PKDResourceType.getType(findExt[findExt.length - 1].toLowerCase())
|
|
286
|
-
readFile("www/certificates/" + item.name, function (file, resType) {
|
|
287
|
-
resType = resType[0]
|
|
288
|
-
var certificates = []
|
|
289
|
-
certificates.push({
|
|
290
|
-
'binaryData': file,
|
|
291
|
-
'resourceType': resType
|
|
292
|
-
})
|
|
293
|
-
DocumentReader.addPKDCertificates(certificates, function (s) {
|
|
294
|
-
console.log("certificate added")
|
|
295
|
-
}, function (e) { console.log(e) })
|
|
296
|
-
}, pkdResourceType)
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}, function (err) { console.log(err) })
|
|
300
|
-
}, function (err) { console.log(err) })
|
|
301
|
-
}
|
|
302
|
-
|
|
303
249
|
function readFile(path, callback, ...items) {
|
|
304
250
|
if (path.substring(0, 8) !== "file:///")
|
|
305
251
|
path = cordova.file.applicationDirectory + path
|
|
@@ -315,48 +261,28 @@ var app = {
|
|
|
315
261
|
}
|
|
316
262
|
|
|
317
263
|
readFile("www/regula.license", function (license) {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
document.getElementById("status").innerHTML = "Ready"
|
|
328
|
-
document.getElementById("status").style.backgroundColor = "green"
|
|
329
|
-
document.getElementById("showScannerButton").addEventListener("click", scan)
|
|
330
|
-
if (window.cordova.platformId == "android")
|
|
331
|
-
document.getElementById("showImagePicker").addEventListener("click", recognizeAndroid)
|
|
332
|
-
if (window.cordova.platformId == "ios")
|
|
333
|
-
document.getElementById("showImagePicker").addEventListener("click", recognize)
|
|
334
|
-
DocumentReader.setConfig({
|
|
335
|
-
functionality: {
|
|
336
|
-
videoCaptureMotionControl: true,
|
|
337
|
-
showCaptureButton: true
|
|
338
|
-
},
|
|
339
|
-
customization: {
|
|
340
|
-
showResultStatusMessages: true,
|
|
341
|
-
showStatusMessages: true
|
|
342
|
-
},
|
|
343
|
-
processParams: {
|
|
344
|
-
scenario: "Mrz",
|
|
345
|
-
doRfid: false,
|
|
346
|
-
},
|
|
347
|
-
}, function (m) { }, function (e) { })
|
|
348
|
-
DocumentReader.getAvailableScenarios(function (s) {
|
|
349
|
-
DocumentReader.isRFIDAvailableForUse(function (r) { postInitialize(JSON.parse(s), r) }, function (e) { })
|
|
350
|
-
}, function (e) { })
|
|
351
|
-
DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA, function (r) { }, function (e) { })
|
|
352
|
-
// addCertificates()
|
|
353
|
-
}, function (error) {
|
|
354
|
-
console.log(error)
|
|
355
|
-
document.getElementById("status").innerHTML = error
|
|
356
|
-
document.getElementById("status").style.backgroundColor = "red"
|
|
357
|
-
})
|
|
264
|
+
var config = new DocReaderConfig()
|
|
265
|
+
config.license = license
|
|
266
|
+
config.delayedNNLoad = true
|
|
267
|
+
DocumentReader.initializeReader(config, function (message) {
|
|
268
|
+
callback = JSON.parse(message)
|
|
269
|
+
if (!callback.success) {
|
|
270
|
+
console.log("Init error: " + callback.error.message)
|
|
271
|
+
document.getElementById("status").innerHTML = "Init error: " + callback.error.message
|
|
272
|
+
return
|
|
358
273
|
}
|
|
359
|
-
|
|
274
|
+
console.log("Init complete")
|
|
275
|
+
document.getElementById("showScannerButton").addEventListener("click", scan)
|
|
276
|
+
document.getElementById("showImagePicker").addEventListener("click", recognize)
|
|
277
|
+
DocumentReader.getAvailableScenarios(function (s) {
|
|
278
|
+
DocumentReader.getIsRFIDAvailableForUse(function (r) { postInitialize(JSON.parse(s), r) }, function (e) { })
|
|
279
|
+
}, function (e) { })
|
|
280
|
+
onInitialized()
|
|
281
|
+
}, function (error) {
|
|
282
|
+
console.log(error)
|
|
283
|
+
document.getElementById("status").innerHTML = error
|
|
284
|
+
document.getElementById("status").style.backgroundColor = "red"
|
|
285
|
+
})
|
|
360
286
|
})
|
|
361
287
|
},
|
|
362
288
|
|
|
@@ -370,4 +296,4 @@ var app = {
|
|
|
370
296
|
},
|
|
371
297
|
}
|
|
372
298
|
|
|
373
|
-
app.initialize()
|
|
299
|
+
app.initialize()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/cordova-plugin-document-reader-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Cordova plugin for reading and validation of identification documents (API framework)",
|
|
5
5
|
"cordova": {
|
|
6
6
|
"id": "@regulaforensics/cordova-plugin-document-reader-api",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="cordova-plugin-document-reader-api" version="
|
|
2
|
+
<plugin id="cordova-plugin-document-reader-api" version="7.2.0"
|
|
3
3
|
xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
4
4
|
<name>DocumentReaderApi</name>
|
|
5
5
|
<description>Cordova plugin Document reader api</description>
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
<source-file src="src/ios/RGLWDocumentReader.m" />
|
|
21
21
|
<header-file src="src/ios/RGLWJSONConstructor.h" />
|
|
22
22
|
<source-file src="src/ios/RGLWJSONConstructor.m" />
|
|
23
|
-
<header-file src="src/ios/
|
|
24
|
-
<source-file src="src/ios/
|
|
23
|
+
<header-file src="src/ios/RGLWConfig.h" />
|
|
24
|
+
<source-file src="src/ios/RGLWConfig.m" />
|
|
25
25
|
<podspec>
|
|
26
26
|
<config>
|
|
27
27
|
</config>
|
|
28
28
|
<pods>
|
|
29
|
-
<pod name="DocumentReader" spec="
|
|
29
|
+
<pod name="DocumentReader" spec="7.2.3545" />
|
|
30
30
|
</pods>
|
|
31
31
|
</podspec>
|
|
32
32
|
</platform>
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
</feature>
|
|
39
39
|
</config-file>
|
|
40
40
|
<framework src="src/android/build.gradle" custom="true" type="gradleReference" />
|
|
41
|
-
<source-file src="src/android/DocumentReader.
|
|
42
|
-
<source-file src="src/android/JSONConstructor.
|
|
43
|
-
<source-file src="src/android/
|
|
44
|
-
<source-file src="src/android/
|
|
41
|
+
<source-file src="src/android/DocumentReader.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
42
|
+
<source-file src="src/android/JSONConstructor.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
43
|
+
<source-file src="src/android/Config.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
44
|
+
<source-file src="src/android/Utils.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
45
45
|
<source-file src="src/android/BluetoothUtil.kt" target-dir="java/cordova.plugin.documentreader" />
|
|
46
46
|
</platform>
|
|
47
47
|
</plugin>
|