Installation Guide for barKoder's Nativescript Barcode Reader SDK
1. Prepare environment #
Install the dependencies and setup your environment
2. Add our barkoder-nativescript package #
To add the barkoder-nativescript package to your project, you have two options. You can either use the barkoder-nativescript package from npm or from a local path.
To use the package from npm run this command:
npm i barkoder-nativescript
if you are using NPM in your project.
If you prefer to use a local package, download the package from https://barkoder.com, unzip the archive and add the package with setting the package path
tns plugin add <path to barkoder-nativescript package>
3. Import package #
Import the Barkoder Constants in your project with:
import { BarkoderConstants } from 'barkoder-nativescript/barkoder-nativescript.common';
4. BarkoderView #
At this point the barkoder-nativescript package is installed and imported in your project. Next step is to add the BarkoderView in your layout.
<Page >
...
<Barkoder:BarkoderView id="barkoderView" class="scanner-container" width="100%" height="70%"/>
...
5. Init BarkoderView in ViewModel and set the License Key #
Inside View-Model we need to init a BarkoderView from layout xml.
export class HelloWorldModel extends Observable implements BarkoderConstants.BarkoderResultCallback {
private barkoderView : any
constructor(args) {
super()
this.barkoderView = args.object.page.getViewById('barkoderView');
this.barkoderView.setLicenseKey("License_Key")
}
scanningFinished(results: any[], thumbnails: any[], resultImage: any): void {
console.log(`${results[0].textualData}`)
console.log(`${results[0].barcodeTypeName}`)
}
6. Ready to Scan Event #
SDK is fully initialized and ready for configuration or to start the scanning process.
this.barkoderView.startScanning(this)
For the complete usage of the barkoder-nativescript package please check our sample.
7. Camera permissions #
Our SDK requires camera permission to be granted in order to use scanning features.On Android, you specify the permissions in App_Resources/Android/src/main/AndroidManifest.xml. However, this plugin specifies the required permissions for you. @nativescript/camera. For iOS you need to specify camera permission in Info.plist file inside your project
<key>NSCameraUsageDescription</key>
<string>Camera permission</string>
8. Licensing #
The SDK will scan barcodes even without a valid license; however all results will be randomly masked with (*) Asterisk characters. By using our software you are agreeing to our End User License Agreement. To obtain a valid license, one should create an account here and either get a trial license (to test the software out) or procure a production license that can be used within a live app.