Installation
To install the Scanbot SDK module you can run the following in your root project folder
- Yarn
- npm
- Expo
yarn add react-native-scanbot-sdk
npm install react-native-scanbot-sdk
npx expo install react-native-scanbot-sdk
Additional setup
Android
Since your application will work with high-resolution images, it is strongly recommended to add the property android:largeHeap="true"
in the <application>
element of your android/app/src/main/AndroidManifest.xml
file, especially for Android <= 7.x.
Processing hi-res images is a memory intensive task and this property will ensure your app has enough heap allocated to avoid OutOfMemoryError
exceptions.
<application ... android:largeHeap="true">
...
</application>
iOS
The iOS SDK comes in various bundles:
NONE
(or default): the default SDK bundle with no additional dataALL
: All available bundles
If you want to go with the default NONE
bundle, you don't have to do any further configuration, since React Native Autolinking will take care of that for you.
However, if you need additional bundles, you have to disable autolinking and include the pods manually.
To disable autolinking, create a react-native.config.js
file in your project folder and paste the following content:
module.exports = {
dependencies: {
'react-native-scanbot-sdk': {
platforms: {ios: null},
},
},
};
Then you can include the desired subspecs/bundles in your ios/Podfile
:
- Example:
pod 'RNScanbotSDK/ALL', :path => '../node_modules/react-native-scanbot-sdk'
The additional bundle and assets can also be directly added into the iOS project by creating a ScanbotSDKOCRData.bundle
and adding it as a resource.
See more about OCR installation
Expo
Integration with Expo is possible only when using a development build. The project is configurable using our config plugin or manually configure the native projects. To utilize the plugin you can add the following in your app config file:
"plugins": [
[
"react-native-scanbot-sdk",
{
"iOSCameraUsageDescription": "Document & Barcode Scanning permission",
"largeHeap": true,
"mavenURLs": true,
"ocrBlobsDirPath": "./ocr_blobs"
}
]
],
iOSCameraUsageDescription
: AddsNSCameraUsageDescription
in Info.plist. The permission can also be added via Expo PermissionslargeHeap
: Addsandroid:largeHeap
property in<application>
element in AndroidManifest.xmlmavenURLs
: Adds Scanbot SDK Maven urls for Android local development. These URLs are already included in our package's build.gradle, but need to be added due to how Expo starts the Android appocrBlobsDirPath
: Addsocr_blobs
for Android and iOS. Specify a path of a directory that contains only .traineddata files.
For Android, the files are copied over from the specified path in android/app/src/main/assets/ocr_blobs.
For iOS, a ScanbotSDKOCRData.bundle
is created and added as a resource, and the files are copied over from the specified path.
See more about OCR installation
Want to scan longer than one minute?
Generate a free trial license to test the Scanbot SDK thoroughly.
Get your free Trial LicenseWhat do you think of this documentation?
What can we do to improve it? Please be as detailed as you like.