@regulaforensics/ionic-native-document-reader 6.9.0 → 7.1.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 -9
- package/example/README.md +8 -6
- package/example/config.xml +5 -8
- package/example/package.json +14 -23
- package/example/src/app/home/home.module.ts +2 -4
- package/example/src/app/home/home.page.ts +82 -159
- package/index.d.ts +324 -342
- package/index.js +250 -96
- package/ngx/index.d.ts +324 -342
- package/ngx/index.js +254 -100
- package/package.json +1 -1
- package/reactExample/.browserslistrc +6 -0
- package/reactExample/.eslintrc.js +17 -0
- package/reactExample/README.md +9 -6
- package/reactExample/android/app/build.gradle +3 -0
- package/reactExample/android/app/capacitor.build.gradle +22 -0
- package/reactExample/android/app/src/main/AndroidManifest.xml +4 -7
- package/reactExample/android/app/src/main/assets/Regula/.gitkeep +0 -0
- package/reactExample/android/app/src/main/res/values/styles.xml +2 -2
- package/reactExample/android/build.gradle +9 -5
- package/reactExample/android/capacitor.settings.gradle +15 -0
- package/reactExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/reactExample/android/gradle/wrapper/gradle-wrapper.properties +2 -1
- package/reactExample/android/gradle.properties +0 -2
- package/reactExample/android/gradlew +164 -105
- package/reactExample/android/gradlew.bat +92 -89
- package/reactExample/android/variables.gradle +14 -12
- package/reactExample/capacitor.config.ts +4 -2
- package/reactExample/cypress/e2e/test.cy.ts +6 -0
- package/reactExample/cypress/fixtures/example.json +5 -0
- package/reactExample/cypress/support/commands.ts +37 -0
- package/reactExample/cypress/support/e2e.ts +20 -0
- package/reactExample/cypress.config.ts +10 -0
- package/reactExample/index.html +116 -0
- package/reactExample/ionic.config.json +6 -6
- package/reactExample/ios/App/App/App.entitlements +0 -1
- package/reactExample/ios/App/App/AppDelegate.swift +0 -11
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +6 -108
- package/reactExample/ios/App/App/Info.plist +4 -4
- package/reactExample/ios/App/App.xcodeproj/project.pbxproj +14 -22
- package/reactExample/ios/App/Podfile +7 -3
- package/reactExample/package.json +58 -82
- package/reactExample/public/assets/.gitkeep +0 -0
- package/reactExample/src/components/ExploreContainer.css +24 -0
- package/reactExample/src/components/ExploreContainer.tsx +14 -0
- package/reactExample/src/main.tsx +11 -0
- package/reactExample/src/pages/Home.tsx +91 -162
- package/reactExample/src/theme/variables.css +6 -0
- package/reactExample/src/vite-env.d.ts +1 -0
- package/reactExample/tsconfig.json +10 -16
- package/reactExample/tsconfig.node.json +9 -0
- package/reactExample/vite.config.ts +16 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-20x20@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-29x29@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x-1.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-40x40@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-60x60@3x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@1x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-76x76@2x.png +0 -0
- package/reactExample/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-83.5x83.5@2x.png +0 -0
- package/reactExample/ios/App/App/capacitor.config.json +0 -6
- package/reactExample/ios/App/App/config.xml +0 -19
- package/reactExample/ios/App/App.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/reactExample/public/assets/icon/icon.png +0 -0
- package/reactExample/public/assets/shapes.svg +0 -1
- package/reactExample/public/index.html +0 -114
- package/reactExample/src/assets/img/id.png +0 -0
- package/reactExample/src/assets/img/portrait.png +0 -0
- package/reactExample/src/index.tsx +0 -22
- package/reactExample/src/react-app-env.d.ts +0 -1
- package/reactExample/src/reportWebVitals.ts +0 -15
- package/reactExample/src/service-worker.ts +0 -80
- package/reactExample/src/serviceWorkerRegistration.ts +0 -142
- /package/reactExample/public/{assets/icon/favicon.png → favicon.png} +0 -0
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
# Regula Document Reader
|
|
1
|
+
# Regula Document Reader SDK for Ionic
|
|
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
|
-
* [Documentation](#documentation)
|
|
10
|
-
* [Additional information](#additional-information)
|
|
11
|
-
|
|
12
9
|
## Documentation
|
|
13
|
-
You can find documentation on API [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/ionic).
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/ionic).
|
|
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
|
|
17
18
|
|
|
18
|
-
|
|
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.
|
package/example/README.md
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# How to build demo application
|
|
2
|
-
1.
|
|
3
|
-
2.
|
|
4
|
-
3.
|
|
2
|
+
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.
|
|
3
|
+
2. Get the trial database at [client.regulaforensics.com/customer/databases](https://client.regulaforensics.com/customer/databases) (`db.dat`)
|
|
4
|
+
3. Download or clone this repository using the command `git clone https://github.com/regulaforensics/DocumentReader-Ionic-Plugin.git`.
|
|
5
|
+
4. Copy the `regula.license` file to the `example/src/assets/` folder.
|
|
6
|
+
5. Copy the `db.dat` file to the `example/src/assets/` folder.
|
|
7
|
+
6. Run the following commands in Terminal:
|
|
5
8
|
```bash
|
|
6
9
|
$ cd example
|
|
7
10
|
$ npm install
|
|
8
11
|
$ npx jetify
|
|
9
12
|
$ ionic cordova prepare
|
|
10
13
|
```
|
|
11
|
-
4. Copy the `regula.license` file to the `example/src/assets` folder.
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
7. Android:
|
|
14
16
|
* Run `ionic cordova build android`, then`ionic 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.
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
8. iOS:
|
|
17
19
|
* Run `ionic cordova build ios`, then `ionic cordova run ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
18
20
|
|
|
19
21
|
|
package/example/config.xml
CHANGED
|
@@ -19,22 +19,17 @@
|
|
|
19
19
|
<preference name="SplashScreen" value="screen" />
|
|
20
20
|
<preference name="SplashScreenDelay" value="3000" />
|
|
21
21
|
<platform name="android">
|
|
22
|
+
<resource-file src="src/assets/db.dat" target="app/src/main/assets/Regula/db.dat"/>
|
|
22
23
|
<framework src="com.android.support:appcompat-v7:+" />
|
|
23
24
|
<config-file parent="/*" target="AndroidManifest.xml">
|
|
24
25
|
<uses-permission android:name="android.permission.NFC" />
|
|
25
26
|
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
|
26
27
|
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
|
27
28
|
</config-file>
|
|
28
|
-
<config-file parent="/manifest/application" target="AndroidManifest.xml">
|
|
29
|
-
<activity android:label="@string/multi_app_name" android:name="com.synconset.MultiImageChooserActivity" android:theme="@style/Theme.AppCompat.Light" />
|
|
30
|
-
</config-file>
|
|
31
29
|
|
|
32
30
|
<preference name="android-minSdkVersion" value="21" />
|
|
33
31
|
<preference name="android-targetSdkVersion" value="33" />
|
|
34
|
-
<preference name="AndroidXEnabled" value="true" />
|
|
35
32
|
<preference name="GradlePluginKotlinEnabled" value="true" />
|
|
36
|
-
<preference name="GradlePluginKotlinCodeStyle" value="official" />
|
|
37
|
-
<preference name="GradlePluginKotlinVersion" value="1.7.10" />
|
|
38
33
|
|
|
39
34
|
<resource-file src="resources/android/xml/network_security_config.xml" target="app/src/main/res/xml/network_security_config.xml" />
|
|
40
35
|
<allow-intent href="market:*" />
|
|
@@ -58,12 +53,15 @@
|
|
|
58
53
|
<splash density="port-xxxhdpi" src="resources/android/splash/drawable-port-xxxhdpi-screen.png" />
|
|
59
54
|
</platform>
|
|
60
55
|
<platform name="ios">
|
|
56
|
+
<resource-file src="src/assets/db.dat" />
|
|
61
57
|
<allow-intent href="itms:*" />
|
|
62
58
|
<allow-intent href="itms-apps:*" />
|
|
63
|
-
<preference default=" " name="CAMERA_USAGE_DESCRIPTION" />
|
|
64
59
|
<config-file parent="NSCameraUsageDescription" target="*-Info.plist">
|
|
65
60
|
<string>To use camera</string>
|
|
66
61
|
</config-file>
|
|
62
|
+
<config-file parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
|
|
63
|
+
<string>To pick images</string>
|
|
64
|
+
</config-file>
|
|
67
65
|
<config-file parent="NFCReaderUsageDescription" target="*-Info.plist">
|
|
68
66
|
<string>To use NFC</string>
|
|
69
67
|
</config-file>
|
|
@@ -136,7 +134,6 @@
|
|
|
136
134
|
<splash height="2436" src="resources/ios/splash/Default-2436h.png" width="1125" />
|
|
137
135
|
<splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
|
|
138
136
|
</platform>
|
|
139
|
-
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
|
|
140
137
|
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
|
|
141
138
|
<plugin name="cordova-plugin-device" spec="2.0.2" />
|
|
142
139
|
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
|
package/example/package.json
CHANGED
|
@@ -13,29 +13,27 @@
|
|
|
13
13
|
},
|
|
14
14
|
"private": true,
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@regulaforensics/cordova-plugin-document-reader-api": "7.1.0",
|
|
17
|
+
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "7.1.0",
|
|
18
|
+
"@regulaforensics/ionic-native-document-reader": "7.1.0",
|
|
19
|
+
"cordova-plugin-camera": "7.0.0",
|
|
20
|
+
"@awesome-cordova-plugins/camera": "6.6.0",
|
|
21
|
+
"@awesome-cordova-plugins/core": "6.6.0",
|
|
22
|
+
"@awesome-cordova-plugins/file": "6.6.0",
|
|
23
|
+
"@awesome-cordova-plugins/splash-screen": "6.6.0",
|
|
24
|
+
"@awesome-cordova-plugins/status-bar": "6.6.0",
|
|
16
25
|
"@angular/common": "~13.3.2",
|
|
17
26
|
"@angular/core": "~13.3.2",
|
|
18
27
|
"@angular/forms": "~13.3.2",
|
|
19
28
|
"@angular/platform-browser": "~13.3.2",
|
|
20
29
|
"@angular/platform-browser-dynamic": "~13.3.2",
|
|
21
30
|
"@angular/router": "~13.3.2",
|
|
22
|
-
"@awesome-cordova-plugins/android-permissions": "^5.28.0",
|
|
23
|
-
"@awesome-cordova-plugins/core": "^5.28.0",
|
|
24
|
-
"@awesome-cordova-plugins/file": "^5.28.0",
|
|
25
|
-
"@awesome-cordova-plugins/image-picker": "^5.28.0",
|
|
26
|
-
"@awesome-cordova-plugins/splash-screen": "^5.28.0",
|
|
27
|
-
"@awesome-cordova-plugins/status-bar": "^5.28.0",
|
|
28
31
|
"@ionic/angular": "^6.0.15",
|
|
29
32
|
"@ionic/cordova-builders": "^6.1.0",
|
|
30
|
-
"cordova-
|
|
31
|
-
"
|
|
32
|
-
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": "6.9.0",
|
|
33
|
-
"@regulaforensics/ionic-native-document-reader": "6.9.0",
|
|
34
|
-
"cordova-android": "^10.1.1",
|
|
33
|
+
"cordova-android": "12.0.1",
|
|
34
|
+
"cordova-ios": "6.3.0",
|
|
35
35
|
"cordova-plugin-add-swift-support": "^2.0.2",
|
|
36
|
-
"cordova-plugin-
|
|
37
|
-
"cordova-plugin-file": "^6.0.2",
|
|
38
|
-
"cordova-plugin-telerik-imagepicker": "^2.3.5",
|
|
36
|
+
"cordova-plugin-file": "8.0.1",
|
|
39
37
|
"core-js": "^3.6.5",
|
|
40
38
|
"rxjs": "~6.6.3",
|
|
41
39
|
"tslib": "^2.0.1",
|
|
@@ -61,7 +59,6 @@
|
|
|
61
59
|
"cordova-plugin-ionic-webview": "^5.0.0",
|
|
62
60
|
"cordova-plugin-splashscreen": "^6.0.0",
|
|
63
61
|
"cordova-plugin-statusbar": "^2.4.3",
|
|
64
|
-
"cordova-plugin-whitelist": "^1.3.5",
|
|
65
62
|
"jasmine-core": "~4.0.1",
|
|
66
63
|
"jasmine-spec-reporter": "~6.0.0",
|
|
67
64
|
"karma": "~6.3.17",
|
|
@@ -79,18 +76,12 @@
|
|
|
79
76
|
"plugins": {
|
|
80
77
|
"@regulaforensics/cordova-plugin-document-reader-api": {},
|
|
81
78
|
"@regulaforensics/cordova-plugin-document-reader-core-fullrfid": {},
|
|
82
|
-
"cordova-plugin-
|
|
83
|
-
"cordova-plugin-telerik-imagepicker": {
|
|
84
|
-
"PHOTO_LIBRARY_USAGE_DESCRIPTION": " "
|
|
85
|
-
},
|
|
79
|
+
"cordova-plugin-camera": {},
|
|
86
80
|
"cordova-plugin-file": {},
|
|
87
|
-
"cordova-plugin-whitelist": {},
|
|
88
81
|
"cordova-plugin-statusbar": {},
|
|
89
82
|
"cordova-plugin-device": {},
|
|
90
83
|
"cordova-plugin-splashscreen": {},
|
|
91
|
-
"cordova-plugin-ionic-webview": {
|
|
92
|
-
"ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
|
|
93
|
-
},
|
|
84
|
+
"cordova-plugin-ionic-webview": {},
|
|
94
85
|
"cordova-plugin-ionic-keyboard": {}
|
|
95
86
|
},
|
|
96
87
|
"platforms": [
|
|
@@ -3,8 +3,7 @@ import { CommonModule } from '@angular/common';
|
|
|
3
3
|
import { IonicModule } from '@ionic/angular';
|
|
4
4
|
import { FormsModule } from '@angular/forms';
|
|
5
5
|
import { RouterModule } from '@angular/router';
|
|
6
|
-
import {
|
|
7
|
-
import { AndroidPermissions } from '@awesome-cordova-plugins/android-permissions/ngx';
|
|
6
|
+
import { Camera } from "@awesome-cordova-plugins/camera/ngx"
|
|
8
7
|
import { DocumentReader } from '@regulaforensics/ionic-native-document-reader/ngx';
|
|
9
8
|
|
|
10
9
|
import { HomePage } from './home.page';
|
|
@@ -22,8 +21,7 @@ import { HomePage } from './home.page';
|
|
|
22
21
|
])
|
|
23
22
|
],
|
|
24
23
|
providers:[
|
|
25
|
-
|
|
26
|
-
AndroidPermissions,
|
|
24
|
+
Camera,
|
|
27
25
|
DocumentReader
|
|
28
26
|
],
|
|
29
27
|
declarations: [HomePage]
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Component, ViewChild, ElementRef } from '@angular/core'
|
|
2
2
|
import { File } from '@awesome-cordova-plugins/file'
|
|
3
|
-
import {
|
|
4
|
-
import { AndroidPermissions } from '@awesome-cordova-plugins/android-permissions/ngx'
|
|
3
|
+
import { Camera, DestinationType, MediaType, PictureSourceType } from '@awesome-cordova-plugins/camera/ngx'
|
|
5
4
|
import { Platform } from '@ionic/angular'
|
|
6
|
-
import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification, ScannerConfig, RecognizeConfig } from '@regulaforensics/ionic-native-document-reader/ngx'
|
|
5
|
+
import { DocumentReader, DocumentReaderScenario, Enum, DocumentReaderCompletion, DocumentReaderResults, DocumentReaderNotification, ScannerConfig, RecognizeConfig, DocReaderConfig } from '@regulaforensics/ionic-native-document-reader/ngx'
|
|
7
6
|
|
|
8
7
|
var selectedScenario = "Mrz"
|
|
9
8
|
var doRfid: boolean = false
|
|
@@ -36,71 +35,54 @@ export class HomePage {
|
|
|
36
35
|
@ViewChild('rfidProgress', { static: false }) rfidProgress: ElementRef
|
|
37
36
|
@ViewChild('cancelButton', { static: false }) cancelButton: ElementRef
|
|
38
37
|
|
|
39
|
-
constructor(public DocumentReader: DocumentReader, public platform: Platform, private
|
|
38
|
+
constructor(public DocumentReader: DocumentReader, public platform: Platform, private camera: Camera) {
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
ionViewDidEnter() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var error2 = e => {
|
|
51
|
-
e = JSON.stringify(e, undefined, 2)
|
|
52
|
-
console.log(e)
|
|
53
|
-
alert(e)
|
|
42
|
+
function onInitialized() {
|
|
43
|
+
app.status.nativeElement.innerHTML = "Ready"
|
|
44
|
+
app.status.nativeElement.style.backgroundColor = "green"
|
|
45
|
+
|
|
46
|
+
DocumentReader.setFunctionality({
|
|
47
|
+
showCaptureButton: true
|
|
48
|
+
})
|
|
54
49
|
}
|
|
55
50
|
|
|
56
|
-
app
|
|
51
|
+
var app = this
|
|
52
|
+
var DocumentReader = this.DocumentReader
|
|
53
|
+
app.cancelButton.nativeElement.addEventListener("click", hideRfidUI)
|
|
57
54
|
updateUI()
|
|
58
55
|
app.status.nativeElement.innerHTML = "loading......"
|
|
59
56
|
app.status.nativeElement.style.backgroundColor = "grey"
|
|
60
57
|
app.platform.ready().then(() => {
|
|
61
|
-
readFile("www/assets", "regula.license", (license) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
readFile("www/assets", "regula.license", (license: string) => {
|
|
59
|
+
var config = new DocReaderConfig()
|
|
60
|
+
config.license = license
|
|
61
|
+
config.delayedNNLoad = true
|
|
62
|
+
DocumentReader.initializeReader(config).then((message: string) => {
|
|
63
|
+
var callback = JSON.parse(message)
|
|
64
|
+
if (!callback.success) {
|
|
65
|
+
var error = "Init error: " + callback.error.message
|
|
66
|
+
console.log(error)
|
|
67
|
+
this.status.nativeElement.innerHTML = error
|
|
68
|
+
this.status.nativeElement.style.backgroundColor = "red"
|
|
69
|
+
return
|
|
71
70
|
}
|
|
71
|
+
console.log("Init complete")
|
|
72
|
+
app.showScannerButton.nativeElement.addEventListener("click", scan)
|
|
73
|
+
app.showImagePicker.nativeElement.addEventListener("click", recognize)
|
|
74
|
+
DocumentReader.getAvailableScenarios().then(sc =>
|
|
75
|
+
DocumentReader.getIsRFIDAvailableForUse().then((canRfid: boolean) =>
|
|
76
|
+
postInitialize(JSON.parse(sc), canRfid)))
|
|
77
|
+
onInitialized()
|
|
72
78
|
})
|
|
73
79
|
})
|
|
74
80
|
})
|
|
75
81
|
|
|
76
|
-
function
|
|
77
|
-
File.resolveDirectoryUrl(File.applicationDirectory + "certificates").then(dir => {
|
|
78
|
-
dir.createReader().readEntries(entries => {
|
|
79
|
-
for (let i = 0; i < entries.length; i++) {
|
|
80
|
-
if (entries[i].isFile) {
|
|
81
|
-
var findExt = entries[i].name.split('.')
|
|
82
|
-
var pkdResourceType = 0
|
|
83
|
-
if (findExt.length > 0)
|
|
84
|
-
pkdResourceType = Enum.PKDResourceType.getType(findExt[findExt.length - 1].toLowerCase())
|
|
85
|
-
readFile("certificates", entries[i].name, (file, resType) => {
|
|
86
|
-
resType = resType[0]
|
|
87
|
-
var certificates = []
|
|
88
|
-
certificates.push({
|
|
89
|
-
'binaryData': file,
|
|
90
|
-
'resourceType': resType
|
|
91
|
-
})
|
|
92
|
-
DocumentReader.addPKDCertificates(certificates).then(s => console.log("certificate added")).catch(e => console.log(e))
|
|
93
|
-
}, pkdResourceType)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
})
|
|
97
|
-
})
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function readFile(dirPath: string, fileName: string, callback, ...items) {
|
|
82
|
+
function readFile(dirPath: string, fileName: string, callback: any, ...items: any) {
|
|
101
83
|
File.resolveDirectoryUrl(File.applicationDirectory + dirPath).then(dir => File.getFile(dir, fileName, null).then(fileEntry => fileEntry.file(file => {
|
|
102
84
|
var reader = new FileReader()
|
|
103
|
-
reader.onloadend = (
|
|
85
|
+
reader.onloadend = (_) => {
|
|
104
86
|
var data = reader.result as String
|
|
105
87
|
data = data.substring(data.indexOf(',') + 1)
|
|
106
88
|
callback(data, items)
|
|
@@ -118,32 +100,27 @@ export class HomePage {
|
|
|
118
100
|
app.rfidProgress.nativeElement.value = rfidProgress
|
|
119
101
|
}
|
|
120
102
|
|
|
121
|
-
function stopRfid() {
|
|
122
|
-
hideRfidUI()
|
|
123
|
-
DocumentReader.stopRFIDReader()
|
|
124
|
-
}
|
|
125
|
-
|
|
126
103
|
function handleCompletion(completion: DocumentReaderCompletion) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (completion.action === Enum.DocReaderAction.COMPLETE)
|
|
133
|
-
if (isReadingRfidCustomUi) {
|
|
134
|
-
if (completion.results.rfidResult !== 1)
|
|
135
|
-
restartRfidUI()
|
|
136
|
-
else {
|
|
137
|
-
hideRfidUI()
|
|
138
|
-
displayResults(completion.results)
|
|
139
|
-
}
|
|
104
|
+
if (isReadingRfidCustomUi) {
|
|
105
|
+
if (completion.action == Enum.DocReaderAction.ERROR) restartRfidUI()
|
|
106
|
+
if (actionSuccess(completion.action) || actionError(completion.action)) {
|
|
107
|
+
hideRfidUI()
|
|
108
|
+
displayResults(completion.results)
|
|
140
109
|
}
|
|
141
|
-
|
|
142
|
-
handleResults(completion.results)
|
|
143
|
-
if (completion.action === Enum.DocReaderAction.TIMEOUT)
|
|
110
|
+
} else if (actionSuccess(completion.action))
|
|
144
111
|
handleResults(completion.results)
|
|
145
112
|
}
|
|
146
113
|
|
|
114
|
+
function actionSuccess(action: number) {
|
|
115
|
+
if (action == Enum.DocReaderAction.COMPLETE || action == Enum.DocReaderAction.TIMEOUT) return true
|
|
116
|
+
return false
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function actionError(action: number) {
|
|
120
|
+
if (action == Enum.DocReaderAction.CANCEL || action == Enum.DocReaderAction.ERROR) return true
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
147
124
|
function showRfidUI() {
|
|
148
125
|
// show animation
|
|
149
126
|
isReadingRfidCustomUi = true
|
|
@@ -152,6 +129,7 @@ export class HomePage {
|
|
|
152
129
|
|
|
153
130
|
function hideRfidUI() {
|
|
154
131
|
// show animation
|
|
132
|
+
DocumentReader.stopRFIDReader()
|
|
155
133
|
restartRfidUI()
|
|
156
134
|
isReadingRfidCustomUi = false
|
|
157
135
|
rfidUIHeader = "Reading RFID"
|
|
@@ -168,77 +146,39 @@ export class HomePage {
|
|
|
168
146
|
}
|
|
169
147
|
|
|
170
148
|
function updateRfidUI(notification: DocumentReaderNotification) {
|
|
171
|
-
if (notification.progress === undefined) return
|
|
172
149
|
if (notification.notificationCode === Enum.eRFID_NotificationCodes.RFID_NOTIFICATION_PCSC_READING_DATAGROUP)
|
|
173
|
-
rfidDescription = notification.dataFileType
|
|
150
|
+
rfidDescription = "ERFIDDataFileType: " + notification.dataFileType
|
|
174
151
|
rfidUIHeader = "Reading RFID"
|
|
175
152
|
rfidUIHeaderColor = "black"
|
|
176
|
-
|
|
153
|
+
if (notification.progress != undefined)
|
|
154
|
+
rfidProgress = notification.progress
|
|
177
155
|
updateUI()
|
|
178
|
-
if (app.platform.is("ios"))
|
|
179
|
-
DocumentReader.setRfidSessionStatus(rfidDescription + "\n" + notification.progress + "%")
|
|
180
156
|
}
|
|
181
157
|
|
|
182
158
|
function customRFID() {
|
|
183
159
|
showRfidUI()
|
|
184
|
-
DocumentReader.readRFID().subscribe(m => handleRfidCompletion(m))
|
|
160
|
+
DocumentReader.readRFID(false, false, false).subscribe((m: string) => handleRfidCompletion(m))
|
|
185
161
|
}
|
|
186
162
|
|
|
187
163
|
function usualRFID() {
|
|
188
164
|
isReadingRfid = true
|
|
189
|
-
DocumentReader.startRFIDReader().subscribe(m => handleRfidCompletion(m))
|
|
165
|
+
DocumentReader.startRFIDReader(false, false, false).subscribe((m: string) => handleRfidCompletion(m))
|
|
190
166
|
}
|
|
191
167
|
|
|
192
168
|
function handleRfidCompletion(raw: string) {
|
|
193
|
-
var
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
console.log(
|
|
200
|
-
|
|
201
|
-
raw
|
|
202
|
-
|
|
203
|
-
} else if (raw.substring(0, taCert.length) === taCert) {
|
|
204
|
-
raw = raw.substring(taCert.length, raw.length)
|
|
205
|
-
console.log(taCert + ": " + raw)
|
|
206
|
-
} else if (raw.substring(0, taSig.length) === taSig) {
|
|
207
|
-
raw = raw.substring(taSig.length, raw.length)
|
|
208
|
-
console.log(taSig + ": " + raw)
|
|
209
|
-
} else
|
|
169
|
+
var idDetected = "rfidOnChipDetectedEvent"
|
|
170
|
+
var idProgress = "rfidOnProgressCompletion"
|
|
171
|
+
var idRetry = "rfidOnRetryReadChipEvent"
|
|
172
|
+
if (raw.substring(0, idDetected.length) === idDetected)
|
|
173
|
+
console.log("chip detected")
|
|
174
|
+
else if (raw.substring(0, idRetry.length) === idRetry)
|
|
175
|
+
console.log("error reading chip, retrying...")
|
|
176
|
+
else if (raw.substring(0, idProgress.length) === idProgress)
|
|
177
|
+
updateRfidUI(DocumentReaderNotification.fromJson(JSON.parse(raw.substring(idProgress.length, raw.length))))
|
|
178
|
+
else
|
|
210
179
|
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(raw)))
|
|
211
180
|
}
|
|
212
181
|
|
|
213
|
-
function onInitialized() {
|
|
214
|
-
app.status.nativeElement.innerHTML = "Ready"
|
|
215
|
-
app.status.nativeElement.style.backgroundColor = "green"
|
|
216
|
-
app.showScannerButton.nativeElement.addEventListener("click", scan)
|
|
217
|
-
if (app.platform.is("android"))
|
|
218
|
-
app.showImagePicker.nativeElement.addEventListener("click", recognizeAndroid)
|
|
219
|
-
if (app.platform.is("ios"))
|
|
220
|
-
app.showImagePicker.nativeElement.addEventListener("click", recognize)
|
|
221
|
-
DocumentReader.setConfig({
|
|
222
|
-
functionality: {
|
|
223
|
-
videoCaptureMotionControl: true,
|
|
224
|
-
showCaptureButton: true
|
|
225
|
-
},
|
|
226
|
-
customization: {
|
|
227
|
-
showResultStatusMessages: true,
|
|
228
|
-
showStatusMessages: true
|
|
229
|
-
},
|
|
230
|
-
processParams: {
|
|
231
|
-
scenario: "Mrz",
|
|
232
|
-
doRfid: false
|
|
233
|
-
},
|
|
234
|
-
})
|
|
235
|
-
DocumentReader.getAvailableScenarios().then(sc =>
|
|
236
|
-
DocumentReader.isRFIDAvailableForUse().then(canRfid =>
|
|
237
|
-
postInitialize(JSON.parse(sc), canRfid)))
|
|
238
|
-
DocumentReader.setRfidDelegate(Enum.RFIDDelegate.NO_PA)
|
|
239
|
-
// addCertificates()
|
|
240
|
-
}
|
|
241
|
-
|
|
242
182
|
function postInitialize(scenarios: Array<any>, canRfid: boolean) {
|
|
243
183
|
var inputs = []
|
|
244
184
|
for (let index of scenarios) {
|
|
@@ -273,7 +213,7 @@ export class HomePage {
|
|
|
273
213
|
|
|
274
214
|
function handleResults(results: DocumentReaderResults) {
|
|
275
215
|
clearResults()
|
|
276
|
-
if (doRfid && !isReadingRfid && results != null
|
|
216
|
+
if (doRfid && !isReadingRfid && results != null) {
|
|
277
217
|
// customRFID()
|
|
278
218
|
usualRFID()
|
|
279
219
|
} else {
|
|
@@ -310,42 +250,25 @@ export class HomePage {
|
|
|
310
250
|
function scan() {
|
|
311
251
|
var config = new ScannerConfig()
|
|
312
252
|
config.scenario = selectedScenario
|
|
313
|
-
DocumentReader.scan(config).subscribe(m =>
|
|
253
|
+
DocumentReader.scan(config).subscribe((m: string) =>
|
|
314
254
|
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
315
255
|
}
|
|
316
256
|
|
|
317
257
|
function recognize() {
|
|
318
|
-
app.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
333
|
-
})).catch(error2)
|
|
334
|
-
}, error2)
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
function recognizeAndroid() {
|
|
338
|
-
app.androidPermissions.checkPermission(app.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then(result => {
|
|
339
|
-
if (result.hasPermission)
|
|
340
|
-
recognize()
|
|
341
|
-
else
|
|
342
|
-
app.androidPermissions.requestPermission(app.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then(result => {
|
|
343
|
-
if (result.hasPermission)
|
|
344
|
-
recognize()
|
|
345
|
-
else
|
|
346
|
-
console.log("storage permission denied")
|
|
347
|
-
}, err => console.log(JSON.stringify(err)))
|
|
348
|
-
}, err => console.log(JSON.stringify(err)))
|
|
258
|
+
app.camera.getPicture({
|
|
259
|
+
destinationType: DestinationType.DATA_URL,
|
|
260
|
+
mediaType: MediaType.PICTURE,
|
|
261
|
+
sourceType: PictureSourceType.PHOTOLIBRARY
|
|
262
|
+
}).then((result: string) => {
|
|
263
|
+
clearResults()
|
|
264
|
+
app.status.nativeElement.innerHTML = "processing image......"
|
|
265
|
+
app.status.nativeElement.style.backgroundColor = "grey"
|
|
266
|
+
var config = new RecognizeConfig()
|
|
267
|
+
config.scenario = selectedScenario
|
|
268
|
+
config.image = result
|
|
269
|
+
DocumentReader.recognize(config).subscribe((m: string) =>
|
|
270
|
+
handleCompletion(DocumentReaderCompletion.fromJson(JSON.parse(m))))
|
|
271
|
+
})
|
|
349
272
|
}
|
|
350
273
|
}
|
|
351
274
|
}
|