@regulaforensics/react-native-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.
Files changed (51) hide show
  1. package/README.md +10 -42
  2. package/RNDocumentReaderApi.podspec +1 -1
  3. package/android/build.gradle +10 -10
  4. package/android/src/main/java/com/regula/documentreader/BluetoothUtil.kt +78 -74
  5. package/android/src/main/java/com/regula/documentreader/Config.kt +692 -0
  6. package/android/src/main/java/com/regula/documentreader/JSONConstructor.kt +2198 -0
  7. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.kt +535 -0
  8. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.kt +11 -0
  9. package/android/src/main/java/com/regula/documentreader/Utils.kt +261 -0
  10. package/example/App.tsx +97 -145
  11. package/example/README.md +37 -0
  12. package/example/android/app/build.gradle +1 -1
  13. package/example/android/app/src/main/java/com/regula/dr/fullrfid/MainApplication.java +0 -1
  14. package/example/android/app/src/main/res/values/styles.xml +1 -2
  15. package/example/android/build.gradle +2 -4
  16. package/example/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  17. package/example/android/gradle.properties +2 -2
  18. package/example/index.js +1 -2
  19. package/example/ios/DocumentReader.xcodeproj/project.pbxproj +8 -4
  20. package/example/ios/Podfile +2 -21
  21. package/example/package-lock.json +3444 -2439
  22. package/example/package.json +28 -28
  23. package/example/react-native.config.js +5 -0
  24. package/index.d.ts +1375 -446
  25. package/index.js +843 -272
  26. package/ios/RGLWConfig.h +48 -0
  27. package/ios/RGLWConfig.m +1312 -0
  28. package/ios/RGLWJSONConstructor.h +173 -69
  29. package/ios/RGLWJSONConstructor.m +1832 -786
  30. package/ios/RNRegulaDocumentReader.h +10 -9
  31. package/ios/RNRegulaDocumentReader.m +388 -587
  32. package/package.json +1 -1
  33. package/android/src/main/java/com/regula/documentreader/Helpers.java +0 -259
  34. package/android/src/main/java/com/regula/documentreader/JSONConstructor.java +0 -1119
  35. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderModule.java +0 -1153
  36. package/android/src/main/java/com/regula/documentreader/RNRegulaDocumentReaderPackage.java +0 -26
  37. package/android/src/main/java/com/regula/documentreader/RegulaConfig.java +0 -830
  38. package/example/.bundle/config +0 -2
  39. package/example/.eslintrc.js +0 -4
  40. package/example/.prettierrc.js +0 -7
  41. package/example/Gemfile +0 -6
  42. package/example/Gemfile.lock +0 -98
  43. package/example/__tests__/App.test.tsx +0 -17
  44. package/example/app.json +0 -4
  45. package/example/babel.config.js +0 -3
  46. package/example/jest.config.js +0 -3
  47. package/example/tsconfig.json +0 -3
  48. package/ios/RGLWRegulaConfig.h +0 -26
  49. package/ios/RGLWRegulaConfig.m +0 -1152
  50. package/ios/RNRegulaDocumentReader.xcodeproj/project.pbxproj +0 -304
  51. package/ios/RNRegulaDocumentReader.xcworkspace/contents.xcworkspacedata +0 -9
package/README.md CHANGED
@@ -1,51 +1,19 @@
1
- # Regula Document Reader (React Native)
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
- ## Additional information
49
- If you have any technical questions, feel free to [contact](mailto:react.support@regulaforensics.com) us or create issue [here](https://github.com/regulaforensics/react-native-document-reader/issues).
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
- To use our SDK in your own app you need to [purchase](https://pipedrivewebforms.com/form/394a3706041290a04fbd0d18e7d7810f1841159) a commercial license.
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.
@@ -14,6 +14,6 @@ Pod::Spec.new do |s|
14
14
  s.source = { :http => 'file:' + __dir__ }
15
15
  s.ios.deployment_target = '11.0'
16
16
  s.source_files = "ios/*.{h,m}"
17
- s.dependency 'DocumentReader', '6.9.3102'
17
+ s.dependency 'DocumentReader', '7.2.3545'
18
18
  s.dependency 'React'
19
19
  end
@@ -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:${project.ext.gradleVersion}"
14
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.ext.kotlinVersion}"
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
- compileSdkVersion 33
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
- targetSdkVersion 33
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:6.9.9406') {
44
+ implementation('com.regula.documentreader:api:7.2.9835') {
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
- class BluetoothUtil {
25
- companion object {
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
- @SuppressLint("StaticFieldLeak")
30
- var bleManager: BLEWrapper? = null
35
+ @SuppressLint("StaticFieldLeak")
36
+ var bleManager: BLEWrapper? = null
31
37
 
32
- @RequiresPermission("android.permission.BLUETOOTH_CONNECT")
33
- private fun requestEnableBle(activity: Activity) {
34
- val enableIntent = Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
35
- activity.startActivityForResult(enableIntent, REQUEST_ENABLE_BT)
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
- private fun requestEnableLocationService(activity: Activity) {
39
- val myIntent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
40
- activity.startActivityForResult(myIntent, REQUEST_ENABLE_LOCATION)
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
- // requestEnableBle() is called after a check for permission
44
- @SuppressLint("MissingPermission")
45
- fun isBlePermissionsGranted(activity: Activity): Boolean {
46
- if (!isLocationServiceEnabled(activity)) {
47
- requestEnableLocationService(activity)
48
- return false
49
- }
50
- deniedBluetoothPermissions(activity)?.let {
51
- requestPermissions(activity, it, BLE_ACCESS_PERMISSION)
52
- return false
53
- }
54
- if (!isBluetoothEnabled(activity)) {
55
- requestEnableBle(activity)
56
- return false
57
- }
58
- return true
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
- private fun deniedBluetoothPermissions(activity: Activity): Array<String>? {
62
- val result = mutableListOf<String>()
63
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
64
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_SCAN))
65
- result.addAll(deniedBluetoothPermission(activity, BLUETOOTH_CONNECT))
66
- } else
67
- result.addAll(deniedBluetoothPermission(activity, ACCESS_FINE_LOCATION))
68
- return result.let { if (it.size > 0) it.toTypedArray() else null }
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
- private fun deniedBluetoothPermission(
72
- activity: Activity,
73
- permission: String
74
- ): Array<String> {
75
- if (checkSelfPermission(activity, permission) != PERMISSION_GRANTED)
76
- return arrayOf(permission)
77
- return arrayOf()
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
- fun startBluetoothService(
81
- activity: Activity,
82
- onConnected: (Boolean) -> Unit,
83
- onDisconnected: () -> Unit,
84
- onReady: () -> Unit
85
- ) {
86
- val bleIntent = Intent(activity, RegulaBleService::class.java)
87
- activity.startService(bleIntent)
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
- activity.bindService(bleIntent, object : ServiceConnection {
90
- override fun onServiceConnected(name: ComponentName, service: IBinder) {
91
- bleManager = (service as RegulaBleService.LocalBinder).service.bleManager
92
- val isBleManagerConnected = bleManager?.isConnected == true
93
- onConnected(isBleManagerConnected)
94
- if (!isBleManagerConnected) {
95
- bleManager?.addCallback(object : BleWrapperCallback() {
96
- override fun onDeviceReady() {
97
- bleManager!!.removeCallback(this)
98
- onReady()
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
  }