@regulaforensics/react-native-document-reader-api 6.9.1 → 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 -42
- package/RNDocumentReaderApi.podspec +1 -1
- package/android/build.gradle +10 -10
- package/android/src/main/java/com/regula/documentreader/BluetoothUtil.kt +78 -74
- package/android/src/main/java/com/regula/documentreader/Config.kt +690 -0
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.kt +2188 -0
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.kt +537 -0
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.kt +11 -0
- package/android/src/main/java/com/regula/documentreader/Utils.kt +256 -0
- package/example/App.tsx +97 -145
- package/example/README.md +37 -0
- package/example/android/app/build.gradle +1 -1
- package/example/android/app/src/main/java/com/regula/dr/fullrfid/MainApplication.java +0 -1
- package/example/android/app/src/main/res/values/styles.xml +1 -2
- package/example/android/build.gradle +2 -4
- package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/example/android/gradle.properties +1 -1
- package/example/index.js +1 -2
- package/example/ios/DocumentReader.xcodeproj/project.pbxproj +8 -4
- package/example/ios/Podfile +0 -1
- package/example/package-lock.json +3062 -2198
- package/example/package.json +24 -23
- package/index.d.ts +296 -135
- package/index.js +234 -115
- package/ios/RGLWConfig.h +48 -0
- package/ios/RGLWConfig.m +1325 -0
- package/ios/RGLWJSONConstructor.h +173 -69
- package/ios/RGLWJSONConstructor.m +1817 -762
- package/ios/RNRegulaDocumentReader.h +6 -5
- package/ios/RNRegulaDocumentReader.m +392 -584
- package/package.json +1 -1
- package/android/src/main/java/com/regula/documentreader/Helpers.java +0 -259
- package/android/src/main/java/com/regula/documentreader/JSONConstructor.java +0 -1119
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.java +0 -1153
- package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.java +0 -26
- package/android/src/main/java/com/regula/documentreader/RegulaConfig.java +0 -830
- package/example/.bundle/config +0 -2
- package/example/.eslintrc.js +0 -4
- package/example/.prettierrc.js +0 -7
- package/example/Gemfile +0 -6
- package/example/Gemfile.lock +0 -98
- package/example/__tests__/App.test.tsx +0 -17
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -3
- package/example/jest.config.js +0 -3
- package/example/tsconfig.json +0 -3
- package/ios/RGLWRegulaConfig.h +0 -26
- package/ios/RGLWRegulaConfig.m +0 -1152
- package/ios/RNRegulaDocumentReader.xcodeproj/project.pbxproj +0 -304
- package/ios/RNRegulaDocumentReader.xcworkspace/contents.xcworkspacedata +0 -9
package/README.md
CHANGED
|
@@ -1,51 +1,19 @@
|
|
|
1
|
-
# Regula Document Reader
|
|
1
|
+
# Regula Document Reader SDK for React Native
|
|
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 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 this repository using the command `git clone https://github.com/regulaforensics/react-native-document-reader.git`.
|
|
17
|
-
3. Run the following commands in Terminal:
|
|
18
|
-
```bash
|
|
19
|
-
$ cd example
|
|
20
|
-
$ npm install
|
|
21
|
-
$ cd ios
|
|
22
|
-
$ pod install
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
**Note**: make sure that Metro Bundler is running when you run your app. Otherwise, run `npx react-native start` command. If it fails to start, run `git init` from Project root, then `npx react-native start`.
|
|
26
|
-
|
|
27
|
-
4. Android:
|
|
28
|
-
* Copy the `regula.license` file to the `example/android/app/src/main/assets` folder.
|
|
29
|
-
* Run `npx react-native run-android` inside `example` folder - this is just one way to run the app. You can also run it directly from within Android Studio. **Note**: `npx react-native log-android` is used to view logs.
|
|
30
|
-
|
|
31
|
-
**Note**: if the running failed with the following error `Error: spawn ./gradlew EACCES`, try to run the following command `chmod +x gradlew` within the `example/android` directory.
|
|
32
|
-
|
|
33
|
-
5. iOS:
|
|
34
|
-
* Copy the `regula.license` file to the `example/ios/DocumentReader` folder.
|
|
35
|
-
* Run `npx react-native run-ios` inside `example` folder - this is just one way to run the app. You can also run it directly from within Xcode.
|
|
36
|
-
|
|
37
|
-
### Troubleshooting license issues
|
|
38
|
-
If you have issues with license verification when running the application, please verify that next is true:
|
|
39
|
-
1. The OS, which you use, is specified in the license (e.g., Android and/or iOS).
|
|
40
|
-
3. The license is valid (not expired).
|
|
41
|
-
4. The date and time on the device, where you run the application, are valid.
|
|
42
|
-
5. You use the latest release version of the Document Reader SDK.
|
|
43
|
-
6. You placed the `license` into the correct folder as described [here](#how-to-build-demo-application).
|
|
44
|
-
|
|
45
9
|
## Documentation
|
|
46
|
-
You can find documentation on API [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
|
|
47
10
|
|
|
48
|
-
|
|
49
|
-
|
|
11
|
+
You can find documentation [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
|
|
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
|
|
50
18
|
|
|
51
|
-
|
|
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/android/build.gradle
CHANGED
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
ext {
|
|
3
|
-
kotlinVersion = '1.8.22'
|
|
4
|
-
gradleVersion = '8.0.2'
|
|
5
|
-
}
|
|
6
|
-
|
|
7
2
|
repositories {
|
|
8
3
|
google()
|
|
9
4
|
mavenCentral()
|
|
10
5
|
}
|
|
11
6
|
|
|
12
7
|
dependencies {
|
|
13
|
-
classpath "com.android.tools.build:gradle
|
|
14
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin
|
|
8
|
+
classpath "com.android.tools.build:gradle:8.1.1"
|
|
9
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22"
|
|
15
10
|
}
|
|
16
11
|
}
|
|
17
12
|
|
|
@@ -19,11 +14,16 @@ apply plugin: 'com.android.library'
|
|
|
19
14
|
apply plugin: 'kotlin-android'
|
|
20
15
|
|
|
21
16
|
android {
|
|
22
|
-
|
|
17
|
+
// Conditional for compatibility with AGP <4.2.
|
|
18
|
+
if (project.android.hasProperty("namespace")) {
|
|
19
|
+
namespace 'com.regula.documentreader'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
compileSdk 34
|
|
23
23
|
|
|
24
24
|
defaultConfig {
|
|
25
25
|
minSdkVersion 21
|
|
26
|
-
|
|
26
|
+
targetSdk 34
|
|
27
27
|
versionCode 1
|
|
28
28
|
versionName "1.0"
|
|
29
29
|
}
|
|
@@ -41,7 +41,7 @@ dependencies {
|
|
|
41
41
|
//noinspection GradleDynamicVersion
|
|
42
42
|
implementation 'com.facebook.react:react-native:+'
|
|
43
43
|
//noinspection GradleDependency
|
|
44
|
-
implementation('com.regula.documentreader:api:
|
|
44
|
+
implementation('com.regula.documentreader:api:7.1.9667') {
|
|
45
45
|
transitive = true
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
// BluetoothUtil.kt
|
|
3
|
+
// DocumentReader
|
|
4
|
+
//
|
|
5
|
+
// Created by Pavel Masiuk on 21.09.2023.
|
|
6
|
+
// Copyright © 2023 Regula. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
1
9
|
package com.regula.documentreader
|
|
2
10
|
|
|
3
11
|
import android.Manifest.permission.*
|
|
@@ -21,88 +29,84 @@ import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelp
|
|
|
21
29
|
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
|
|
22
30
|
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
private const val REQUEST_ENABLE_LOCATION = 196
|
|
27
|
-
private const val REQUEST_ENABLE_BT = 197
|
|
32
|
+
const val REQUEST_ENABLE_LOCATION = 196
|
|
33
|
+
const val REQUEST_ENABLE_BT = 197
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
|
|
35
|
+
@SuppressLint("StaticFieldLeak")
|
|
36
|
+
var bleManager: BLEWrapper? = null
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
@RequiresPermission("android.permission.BLUETOOTH_CONNECT")
|
|
39
|
+
fun requestEnableBle(activity: Activity) {
|
|
40
|
+
val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
|
|
41
|
+
activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
|
|
42
|
+
}
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
fun requestEnableLocationService(activity: Activity) {
|
|
45
|
+
val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
|
46
|
+
activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
|
|
47
|
+
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
// requestEnableBle() is called after a check for permission
|
|
50
|
+
@SuppressLint("MissingPermission")
|
|
51
|
+
fun isBlePermissionsGranted(activity: Activity): Boolean {
|
|
52
|
+
if (!isLocationServiceEnabled(activity)) {
|
|
53
|
+
requestEnableLocationService(activity)
|
|
54
|
+
return false
|
|
55
|
+
}
|
|
56
|
+
deniedBluetoothPermissions(activity)?.let {
|
|
57
|
+
requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
if (!isBluetoothEnabled(activity)) {
|
|
61
|
+
requestEnableBle(activity)
|
|
62
|
+
return false
|
|
63
|
+
}
|
|
64
|
+
return true
|
|
65
|
+
}
|
|
60
66
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
|
|
68
|
+
val result = mutableListOf<String>()
|
|
69
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
70
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
|
|
71
|
+
result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
|
|
72
|
+
} else
|
|
73
|
+
result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
|
|
74
|
+
return result.let { if (it.size > 0) it.toTypedArray() else null }
|
|
75
|
+
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
fun deniedBluetoothPermission(
|
|
78
|
+
activity: Activity,
|
|
79
|
+
permission: String
|
|
80
|
+
): Array<String> {
|
|
81
|
+
if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
|
|
82
|
+
return arrayOf(permission)
|
|
83
|
+
return arrayOf()
|
|
84
|
+
}
|
|
79
85
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
fun startBluetoothService(
|
|
87
|
+
activity: Activity,
|
|
88
|
+
onConnected: (Boolean) -> Unit,
|
|
89
|
+
onDisconnected: () -> Unit,
|
|
90
|
+
onReady: () -> Unit
|
|
91
|
+
) {
|
|
92
|
+
val bleIntent = Intent(activity, RegulaBleService::class.java)
|
|
93
|
+
activity.startService(bleIntent)
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
})
|
|
95
|
+
activity.bindService(bleIntent, object : ServiceConnection {
|
|
96
|
+
override fun onServiceConnected(name: ComponentName, service: IBinder) {
|
|
97
|
+
bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
|
|
98
|
+
val isBleManagerConnected = bleManager?.isConnected == true
|
|
99
|
+
onConnected(isBleManagerConnected)
|
|
100
|
+
if (!isBleManagerConnected) {
|
|
101
|
+
bleManager?.addCallback(object : BleWrapperCallback() {
|
|
102
|
+
override fun onDeviceReady() {
|
|
103
|
+
bleManager!!.removeCallback(this)
|
|
104
|
+
onReady()
|
|
101
105
|
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
|
|
105
|
-
}, 0)
|
|
106
|
+
})
|
|
107
|
+
}
|
|
106
108
|
}
|
|
107
|
-
|
|
109
|
+
|
|
110
|
+
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
|
|
111
|
+
}, 0)
|
|
108
112
|
}
|