Ionic Barcode Scanner


Ionic Barcode Scanner Native Plugin – Barcode scanner provides the native barcode scanning functionality in Ionic Framework. This Plugin uses Camera view to scan the barcode and returns the data. Here in this tutorial we are going to explain how you can use the phonegap-plugin-barcodescanner plugin.


Ionic Barcode Scanner Native Plugin Example

You first need to install the cordova plugin phonegap-plugin-barcodescanner

Installation

Ionic Barcode Scanner Native Plugin Example:

$ ionic cordova plugin add phonegap-plugin-barcodescanner
$ npm install --save @ionic-native/barcode-scanner

Supported Platforms

  • Android
  • Blackberry 10
  • Browser
  • IOS
  • Windows

Example

Ionic Barcode Reader Example:

import { BarcodeScanner } from '@ionic-native/barcode-scanner';

constructor(private barcodeScanner: BarcodeScanner) { }

...


this.barcodeScanner.scan().then((barcodeData) => {
 // Success! Barcode data is here
}, (err) => {
    // An error occurred
});

Instance Members

  • scan(options)– This is used to open the barcode scanner.
  • encode(type, data)– This encodes data into barcode. Where type is type of encoding and data is data to be encoded.

Barcode Scanner Options

Param Type Details
preferFrontCamera(optional) boolean Prefer front camera(IOS& Android).
showFlipCameraButton(optional) boolean This is used to Show flip camera button(IOS& Android).
showTorchButton(optional) boolean This is used to show torch button(IOS& Android).
disableAnimations(optional) boolean Disable animations(IOS).
disableSuccessBeep(optional) boolean Disable success beep(IOS).
prompt(optional) string Prompt text(Android Supported Only).
formats(optional) string Formats separated by commas.
orientation(optional) string This is used to set the orientation(Android Supported Only).
torchOn(optional) boolean Open torch(Android Supported Only).
resultDisplayDuration(optional) number Display scanned text for X ms. 0 suppresses it entirely, default 1500(Android Supported Only).

Barcode Scan Result

Param Type
format ‘QR_CODE’ | ‘DATA_MATRIX’ | ‘UPC_E’ | ‘UPC_A’ | ‘EAN_8’ | ‘EAN_13’ | ‘CODE_128’ | ‘CODE_39’ | ‘CODE_93’ | ‘CODABAR’ | ‘ITF’ | ‘RSS14’ | ‘RSS_EXPANDED’ | ‘PDF417’ | ‘AZTEC’ | ‘MSI’
cancelled boolean
text string

Advertisements

Add Comment

📖 Read More