Need help upgrading to Ionic Framework 4.0? Get assistance with our Enterprise Migration Services EXPLORE NOW

Barcode Scanner

Improve this doc

The Barcode Scanner Plugin opens a camera view and automatically scans a barcode, returning the data back to you.

Requires Cordova plugin: phonegap-plugin-barcodescanner. For more info, please see the BarcodeScanner plugin docs.



  1. Install the Cordova and Ionic Native plugins:
    $ ionic cordova plugin add phonegap-plugin-barcodescanner
    $ npm install --save @ionic-native/barcode-scanner@4
  2. Add this plugin to your app's module

Supported platforms


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

constructor(private barcodeScanner: BarcodeScanner) { }


this.barcodeScanner.scan().then(barcodeData => {
 console.log('Barcode data', barcodeData);
}).catch(err => {
    console.log('Error', err);

Instance Members



Open the barcode scanner.

Param Type Details
options BarcodeScannerOptions

Optional options to pass to the scannerOptional

Returns: Promise<any> Returns a Promise that resolves with scanner data, or rejects with an error.

encode(type, data)

Encodes data into a barcode. NOTE: not well supported on Android

Param Type Details
type string

Type of encoding

data any

Data to encode

Returns: Promise<any>


Param Type Details
preferFrontCamera boolean

Prefer front camera. Supported on iOS and Android.

showFlipCameraButton boolean

Show flip camera button. Supported on iOS and Android.

showTorchButton boolean

Show torch button. Supported on iOS and Android.

disableAnimations boolean

Disable animations. Supported on iOS only.

disableSuccessBeep boolean

Disable success beep. Supported on iOS only.

prompt string

Prompt text. Supported on Android only.

formats string

Formats separated by commas. Defaults to all formats except PDF_417 and RSS_EXPANDED.

orientation string

Orientation. Supported on Android only. Can be set to portrait or landscape. Defaults to none so the user can rotate the phone and pick an orientation.

torchOn boolean

Launch with the torch switched on (if available). Supported on Android only.

resultDisplayDuration number

Display scanned text for X ms. 0 suppresses it entirely, default 1500. Supported on Android only.



Param Type Details
format | 'QR_CODE' | 'DATA_MATRIX' | 'UPC_E' | 'UPC_A' | 'EAN_8' | 'EAN_13' | 'CODE_128' | 'CODE_39' | 'CODE_93' | 'CODABAR' | 'ITF' | 'RSS14' | 'RSS_EXPANDED' | 'PDF_417' | 'AZTEC' | 'MSI'
cancelled boolean
text string