Skip to content

Commit

Permalink
Release 43.0.0 (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
renatoAnyline authored Feb 21, 2023
1 parent db57175 commit edda6c0
Show file tree
Hide file tree
Showing 100 changed files with 3,602 additions and 6,118 deletions.
291 changes: 10 additions & 281 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,295 +6,24 @@
# Anyline React-Native Plugin

[Anyline](https://www.anyline.io) is mobile OCR SDK, which can be configured by yourself to scan all kinds of numbers, characters, text and codes.
[Anyline](https://anyline.com) is mobile OCR SDK, which can be configured by yourself to scan all kinds of numbers, characters, text and codes.

The plugin enables the connection to the SDK via React-Native.


## Update to >= 5.0
## File summary

* `example` - Example app source code
* `plugin` - Anyline React Native plugin
* `README.md` - This readme.
* `LICENSE.md` - The license file.

If you use this plugin with a equal or greater version then 5.0, you can use our new Anyline structure, which will provide the whole configuration of every SDK Feature through the config file. If you use the the 'scan' call in your Javascript files, you have to use a new config style.
The old calls with the old configurations will still work.
## Getting Started

Check out our getting-started section here: https://documentation-preview.anyline.com/react-native-plugin-component/43.0.0/getting-started.html

## Requirements:

### iOS

Platform >= 12


### Android

minSDK >= 21

## Example

Take a look into [example/RNExampleApp/src/Result.js](https://github.com/Anyline/anyline-ocr-react-native-module/tree/master/example/RNExampleApp/src/Result.js) to see the implementation.

## Quick Start Guide

### 1. Get a License
Get your [trial license](https://anyline.com/free-demos/) to try Anyline inside your app.
Reach out to our sales team to get a [commercial license](https://anyline.com/contact-sales/).

### 2. Get the Anyline react-native plugin

Via npm:

```bash
npm i anyline-ocr-react-native-module
```

or download / clone this repository and copy the content of the `plugin` folder into `node_modules` inside a new folder named `anyline-ocr-react-native-module`:

```bash
project
│ android
│ ios
└─── node_modules
│ ...
└─── anyline-ocr-react-native-module
```

Install react-native-cli

```bash
npm i -g react-native-cli
```

Link the project. Run as root inside your project root:

```bash
react-native link
```

### 3. Get the native Dependencies

#### Android

##### Setup Packages

The package name must match with the bundleID from your Anyline license.

##### Add the Anyline package

Open `MainApplication.java` inside your native Android folder of your project:

Import `AnylinePackage`

```Java
import com.anyline.reactnative.AnylinePackage;
```
and add the package to your `getPackages` method

```Java
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new AnylinePackage()
);
}
```

##### Add repositories to your app

You need to add the Anyline and the google repository to your `build.gradle`, so gradle does know, where to find these.

To do this open `yourApp/android/build.gradle` and add this to allprojects:

```
allprojects {
repositories {
...
google()
maven {
url 'https://anylinesdk.blob.core.windows.net/maven/'
}
}
}
```

#### Issues
Strict mode does not allow function declarations in a lexically nested statement.

http://stackoverflow.com/a/41076153/2157717

duplicate files during packaging of APK
```
packagingOptions {
pickFirst 'lib/armeabi-v7a/libgnustl_shared.so'
pickFirst 'lib/x86/libgnustl_shared.so'
}
```
#### iOS

##### Podfile
- Copy the [Podfile](https://github.com/Anyline/anyline-ocr-react-native-module/blob/master/example/RNExampleApp/ios/Podfile)
from our example Project into your native iOS root folder.
- Change the target and project of the Podfile to your project name.
- ```pod update```
- if you get an error about `node_modules` dependencies initialize your project with `npm install` first.

##### Permissions
Add camera permissions to `Info.plist`
```
Privacy - Camera Usage Description
```
Add also every other permission you want to configure in your `config.js` (vibrate, sound).

##### Anyline License
Your BundleIdentifier of your app has to match with your bundleID from your Anyline License.

### 4. Import the plugin into your JavaScript file
```JavaScript
import AnylineOCR from 'anyline-ocr-react-native-module';
```
### 5. Import the config file
```JavaScript
import config from './config.js';
```
Add and import a JSON file with the proper structure and elements. The JSON config contains:

1. The license key

2. Options field with
- AnylineSDK config parameter
- “segment”: which contains the scanModes for the UI Segment (e.g. switch between Analog and Digital) - optional
3. OCR field with (Only if you want to use the OCR module)
- your custom training data
- RegEx validation

If you want to get detailed information about the config JSON, check out the official [documentation](https://documentation.anyline.io/toc/view_configuration/index.html).

### 6. Call the Anyline component

#### Callbacks

```JavaScript
AnylineOCR.setup(
JSON.stringify(config),
'scan',
this.onResult,
this.onError
);
```

#### Promise
```JavaScript
const openAnyline = async () => {
...

try {
const result = await AnylineOCR.setupPromise(JSON.stringify(config), 'scan');
} catch(error) {
console.error(error);
}

...
}
```

##### Deprecated
```JavaScript
AnylineOCR.setupScanViewWithConfigJson(
JSON.stringify(config),
'scan',
this.onResult,
this.onError
);
```



### 7. Add TrainData to the OCR Module
If you are using the `ANYLINE_OCR` module, you'll have to add some `traineddata`. There are some predefined `traineddata` which
you can find in the example app. Also the OCR Config has to reflect the path. Check the VoucherConfig.js in the [example/RNExampleApp/config](https://github.com/Anyline/anyline-ocr-react-native-module/tree/master/example/RNExampleApp/config) folder.

> __IMPORTANT:__ The trainedFiles have to be directly in the Asset folder in Android.
#### iOS
```
ios
└─── myTrainedData.traineddata
```

#### Android
```
android
└─── app
└─── src
└─── main
└─── assets
└─── myTrainedData.traineddata || myTrainedData.any
```


## Props

| Key | Type | Default | Description |
| --- | --- | --- | --- |
| config | string | \*required | config (JSON String)|
| scanMode | string | \*required | In the new Version, this is always 'scan', and the scanMode is declared through the configuration |
| onResult | function | \*required | The function you pass will be the onResult callback. Use this callback to handle the found scan results. |
| onError | function | \*required | The onError function will be called when the AnylinePlugin encounters an error. Handle the error messages in this method. |

### config
Stringified JSON with all the configurations, detailed information [here](https://documentation.anyline.io/toc/view_configuration/index.html).

Keep in mind, that you have to add every permission to your project, you add in the config (vibrateOnResult -> vibration permission)

### onResult Function
Callback -> Stringified JSON
```JavaScript
{
reading : 'Result of the Scan',
imagePath : 'path to cropped image',
fullImagePath : 'path to full image',
barcode : 'result of the simultaneous barcode scanning',
scanMode : 'selected scanMode',
meterType : 'meter type'
}
```
More information about the simultaneous barcode scanning [here](https://documentation.anyline.io/toc/modules/overview.html#anyline-modules-simultaneous-barcode-scanning).

### onError Function
Callback -> String
- String errorMessage

## Additional Functions

#### getLicenseExpiryDate
Get the exparation date of the provided license. Returns a string.
```JavaScript
import AnylineOCR, { getLicenseExpiryDate } from 'anyline-ocr-react-native-module';

...

console.log(getLicenseExpiryDate(myLicenseString)); // 'YYYY-MM-DD'
...
```


## Images

Keep in mind, all the images are saved in the cache directory of the app. For performance reasons, we only provide the
path as string, so we don't have to transfer the whole image through the bridge. Please be aware, that you should not
use the images in the cache directory for persistent storage, but store the images in a location of your choice for persistence.

## Get Help (Support)

We don't actively monitor the Github Issues, please raise a support request using the [Anyline Helpdesk](https://anyline.atlassian.net/servicedesk/customer/portal/2/group/6).
When raising a support request based on this Github Issue, please fill out and include the following information:

```
Support request concerning Anyline Github Repository: anyline-ocr-react-native-module
```

Thank you!
## Documentation

Check out our developer guide here: https://documentation-preview.anyline.com/react-native-plugin-component/43.0.0/index.html

## License

Expand Down

This file was deleted.

4 changes: 2 additions & 2 deletions example/RNExampleApp/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ android {
compileSdkVersion rootProject.ext.compileSdkVersion

defaultConfig {
applicationId "com.anyline.example.reactnative"
applicationId "com.anyline.examples.reactnative"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5
versionName "42.2.0"
versionName "43.0.0"
multiDexEnabled true

}
Expand Down
39 changes: 19 additions & 20 deletions example/RNExampleApp/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.anyline.example.reactnative">
package="com.anyline.examples.reactnative">

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.VIBRATE" />


<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:name=".MainApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustResize"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
android:roundIcon="@mipmap/ic_launcher_round"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
android:exported="true"
android:label="@string/app_name"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.anyline.example.reactnative;
package com.anyline.examples.reactnative;

import com.facebook.react.ReactActivity;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.anyline.example.reactnative;
package com.anyline.examples.reactnative;

import android.app.Application;

Expand Down
4 changes: 3 additions & 1 deletion example/RNExampleApp/android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ RELEASE_STORE_PASSWORD=KEYSTORE_PASSWORD
RELEASE_KEY_PASSWORD=KEYSTORE_PASSWORD

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.75.1
FLIPPER_VERSION=0.75.1
android.jetifier.ignorelist=moshi-1.14.0
android.jetifier.blacklist=moshi-1.14.0
Binary file not shown.
Loading

0 comments on commit edda6c0

Please sign in to comment.