 # barKoder Barcode Scanner SDK for mobile Nativescript Apps
## Ultimate software-based barcode scanning solution for Nativescript

The [barKoder Barcode Scanner SDK](https://barkoder.com/barcode-scanner-sdk) Nativescript plugin grants an easy to use Nativescript solution with a great and option-rich interface that can be integrated in both iOS and Android apps. Integrating the barKoder Barcode Scanner SDK into your Enterprise or Consumer-facing mobile apps will instantly transform your user's smartphones and tablets into rugged barcode scanning devices without the need to procure and maintain expensive and sluggish hardware devices that have a very short life span.

Even though the barKoder barcode scanner SDK is a relatively new product, it is already more advanced than any competitor API's. Its robust barcode reading engine can be used to read the content of the most widely used barcodes with lightning fast speed and unprecedented recognition rate:

1D - [Codabar](https://barkoder.com/barcode-types/codaba), [Code 11](https://barkoder.com/barcode-types/code-11), [Code 25](https://barkoder.com/barcode-types/code-25), [Code 39](https://barkoder.com/barcode-types/code-39), [Code 93](https://barkoder.com/barcode-types/code-93), [Code 128](https://barkoder.com/barcode-types/code-128), [DotCode](https://barkoder.com/barcode-types/dotcode), [EAN-8](https://barkoder.com/barcode-types/ean-upc-code), [EAN-13](https://barkoder.com/barcode-types/ean-upc-code), [Interleaved 2 of 5](https://barkoder.com/barcode-types/code-25), [ITF-14](https://barkoder.com/barcode-types/code-25), [MSI Plessey](https://barkoder.com/barcode-types/msi-plessey), [Pharmacode](https://barkoder.com/barcode-types/code-32), [Telepen](https://barkoder.com/barcode-types/telepen), [UPC-A](https://barkoder.com/barcode-types/ean-upc-code) & [UPC-E](https://barkoder.com/barcode-types/ean-upc-code)
2D - [Aztec Code](https://barkoder.com/barcode-types/aztec), [Aztec Compact](https://barkoder.com/barcode-types/aztec), [Data Matrix](https://barkoder.com/barcode-types/data-matrix), [DotCode](https://barkoder.com/barcode-types/dotcode),[PDF417](https://barkoder.com/barcode-types/pdf417), [Micro PDF417](https://barkoder.com/barcode-types/pdf417), [QR Code](https://barkoder.com/barcode-types/qr-code) & [Micro QR Code](https://barkoder.com/barcode-types/qr-code)

The [barKoder SDK](https://barkoder.com/) features multiple algorithms that handle a wide variety of barcode scanning scenarios with unprecedented performance in terms of speed and success rate:
* [DPM Mode](https://barkoder.com/dpm-barcode-scanner-sdk) - Specially designed scanning template for decoding Data Matrix barcodes engraved using any Direct Part Marking (DPM) technique;
* [MatrixSight](https://barkoder.com/matrixsight) - MatrixSight® is the ultimate 2D barcode recognition system. Its capabilities transcend beyond anything that a traditional barcode scanner, be that hardware or software-based, can achieve. Simply put, there's no QR Code or Data Matrix barcode that is safe from the barKoder MatrixSight® algorithm. They can have absolutely no finder, alignment or timing patters and can even miss entire data segments but that still won't keep their data safe from being read;
* [Segment Decoding](https://barkoder.com/segment-decoding) - The advanced barcode localization logics that are part of the Segment Decoding® technique elevated the barKoder SDK into the most powerful scanning API when it comes to 1D barcode recognition, regardless whether the barcodes have been deformed, crumpled, wrinkled and otherwise altered. Even if it goes to a degree where a straight line can't pass through all its bars, a limitation that other decoders, including hardware ones can't alleviate. Segment Decoding® is unmatched in its performance levels and pattern matching capabilities, amortizing even the highest degree of barcode damages, including printing errors, label damage, scanner angles, low print quality, as well as various other levels of physical damage or environmental conditionings. The fact that the data can be extracted even from 1D barcodes that have significant deformations along their Z axis, makes barKoder especially handy when trying to recognize barcodes found on test tubes, bottles and other surfaces with rounded, curved, hollowed or otherwise irregular shapes;
* [VIN Barcode Scanning Mode](https://barkoder.com/vin-scanning-mode) - When you combine MatrixSight® & Segment Decoding®, the result is breathtaking and leads to the most advanced VIN barcode scanner on the market, able to capture the data even within the most stubborn & difficult to read VIN-powered Code 39, Code 128, Data Matrix & QR Codes;
* [DeBlur Mode](https://barkoder.com/deblur-mode) - Whether there's lens, motion or focus blur present in EAN or UPC barcodes, the barKoder DeBlur Mode alleviates it fully and doesn't allow the scanning experience to suffer;
* [PDF417-LineSight](https://barkoder.com/pdf417-linesight) - The robust PDF417 barcode scanner SDK that is offered by barKoder can detect even the most severely damaged PDF417 codes, including samples missing their start and stop patterns, stop row indicators or even entire data columns, making it the sublime choice for apps that need to reliably scan US or Canadian driver's licenses, South African vehicle license discs or driver's licenses, as well as various types of ID's such as Military, Argentinian, Colombian or South African Smart ID Cards.
* [Batch MultiScan](https://barkoder.com/batch-multiscan) - The Batch MultiScan feature of the barKoder Barcode Scanner SDK for mobile apps and websites, will enable your users to decode multiple barcodes regardless of their type or size in one go. The barKoder API covers all common 1D and 2D barcode symbologies, enabling intuitive and fast data capture while delivering an accuracy of at least 99%, even under the most difficult scanning conditions. Whether in inventory counting, on the last mile or in manufacturing, our fast and accurate Batch MultiScan algorithm greatly increases efficiency and helps create friction-less internal and external processes. The Batch MultiScan works with smartphones, tablets and industrial cameras, enabling true mobility wherever it’s applied.
* [DPM Recognition Mode](https://barkoder.com/dpm-barcode-scanner-sdk) - barKoder SDK's unique algorithms and features provided all the necessary conditions for creating a special mode for decoding even the most challenging Data Matrix barcodes, i.e. those engraved utilizing the Direct Part Marking (DPM) methods, something that previously was only possible with extremely expensive and specialized hardware scanners. Now all you need to achieve such barcode reading levels is your own personal smart device!

You can check out our free demo app Barcode Scanner by barKoder available both via [Apple App Store](https://apps.apple.com/us/app/barkoder-scanner/id6443715409?uo=2) & [Google Play Store](https://play.google.com/store/apps/details?id=com.barkoder.demoscanner).

## Trial License

If you run the barKoder Barcode Scanner SDK without a valid trial or production license, all results upon successful barcode scans will be partially masked by asterisks (*). You can get a trial license simply by [registering on the barKoder Portal](https://barkoder.com/register) and utilizing the self-service for [Evaluation License Generation](https://barkoder.com/spr/new)! Each trial license will be good for an initial duration of 30 days and can be deployed to up to 25 devices. For any custom requirements, contact our sales team via sales@barkoder.com

Note that a trial license is only supposed to be utilized in a development or staging environment.

## Free Developer Support

Our support is completely free for integration or testing purposes and granted through the [barKoder Portal](https://barkoder.com/login). After registering and logging into your account, you only need to submit a [Support Issue](https://barkoder.com/issues) form. Alternatively, you can contact us by email via support@barkoder.com.


# Installation Guide for barKoder's Nativescript Barcode Reader SDK

This is a guide for the barKoder [NativeScript Plugin]

## 1. Prepare environment
Install the dependencies and [setup your environment](https://docs.nativescript.org/setup)

## 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](https://www.npmjs.com/package/barkoder-nativescript) run this command:
    
   ```c
    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](https://barkoder.com/repository), 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:
   ```typescript 
    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.
   ```xml
   
   <Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo"
      xmlns:Barkoder="barkoder-nativescript/barkoder-nativescript.common">
      ...

      <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.
   ```typescript 
  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.
   ```typescript
   
   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](https://www.npmjs.com/package/@nativescript/camera)
 . For iOS you need to specify camera permission in **Info.plist** file inside your project
   ```swift 
    <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](https://barkoder.com/EULA). To obtain a valid license, one should create an account [here](https://barkoder.com/register) and either get a trial license (to test the software out) or procure a production license that can be used within a live app.
   
