Skip to content

Commit 1b054ca

Browse files
author
Jenkins
committed
7.1.0
1 parent 5048a96 commit 1b054ca

50 files changed

Lines changed: 11308 additions & 9206 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,19 @@
1-
# Regula Document Reader (React Native)
1+
# Regula Document Reader SDK for React Native
2+
23
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.
34

45
You can use native camera to scan the documents or image from gallery for extract all data from it.
56

67
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.
78

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-
459
## Documentation
46-
You can find documentation on API [here](https://docs.regulaforensics.com/develop/doc-reader-sdk/mobile/react-native).
4710

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
5018

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.

RNDocumentReaderApi.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Pod::Spec.new do |s|
1414
s.source = { :http => 'file:' + __dir__ }
1515
s.ios.deployment_target = '11.0'
1616
s.source_files = "ios/*.{h,m}"
17-
s.dependency 'DocumentReader', '6.9.3102'
17+
s.dependency 'DocumentReader', '7.1.3379'
1818
s.dependency 'React'
1919
end

android/build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
buildscript {
2-
ext {
3-
kotlinVersion = '1.8.22'
4-
gradleVersion = '8.0.2'
5-
}
6-
72
repositories {
83
google()
94
mavenCentral()
105
}
116

127
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"
1510
}
1611
}
1712

1813
apply plugin: 'com.android.library'
1914
apply plugin: 'kotlin-android'
2015

2116
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
2323

2424
defaultConfig {
2525
minSdkVersion 21
26-
targetSdkVersion 33
26+
targetSdk 34
2727
versionCode 1
2828
versionName "1.0"
2929
}
@@ -41,7 +41,7 @@ dependencies {
4141
//noinspection GradleDynamicVersion
4242
implementation 'com.facebook.react:react-native:+'
4343
//noinspection GradleDependency
44-
implementation('com.regula.documentreader:api:6.9.9406') {
44+
implementation('com.regula.documentreader:api:7.1.9667') {
4545
transitive = true
4646
}
4747
}
Lines changed: 78 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
19
package com.regula.documentreader
210

311
import android.Manifest.permission.*
@@ -21,88 +29,84 @@ import com.regula.documentreader.api.internal.permission.BluetoothPermissionHelp
2129
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isBluetoothEnabled
2230
import com.regula.documentreader.api.internal.permission.BluetoothSettingsHelper.isLocationServiceEnabled
2331

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
2834

29-
@SuppressLint("StaticFieldLeak")
30-
var bleManager: BLEWrapper? = null
35+
@SuppressLint("StaticFieldLeak")
36+
var bleManager: BLEWrapper? = null
3137

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+
}
3743

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+
}
4248

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+
}
6066

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+
}
7076

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+
}
7985

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)
8894

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()
101105
}
102-
}
103-
104-
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
105-
}, 0)
106+
})
107+
}
106108
}
107-
}
109+
110+
override fun onServiceDisconnected(name: ComponentName) = onDisconnected()
111+
}, 0)
108112
}

0 commit comments

Comments
 (0)