Skip to main content

QR Scanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps.

Requires Cordova plugin: cordova-plugin-qrscanner. For more info, please see the QR Scanner plugin docs.

https://github.com/bitpay/cordova-plugin-qrscanner

Stuck on a Cordova issue?

Don't waste precious time on plugin issues.

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.

Installation#

$ npm install cordova-plugin-qrscanner $ npm install @ionic-native/qr-scanner $ ionic cap sync

Supported Platforms#

  • Android
  • Browser
  • iOS
  • Windows

Capacitor#

Not Compatible

Usage#

React#

Learn more about using Ionic Native components in React

Angular#

import { QRScanner, QRScannerStatus } from '@ionic-native/qr-scanner/ngx';

constructor(private qrScanner: QRScanner) { }
...
// Optionally request the permission earlythis.qrScanner.prepare()  .then((status: QRScannerStatus) => {     if (status.authorized) {       // camera permission was granted

       // start scanning       let scanSub = this.qrScanner.scan().subscribe((text: string) => {         console.log('Scanned something', text);
         this.qrScanner.hide(); // hide camera preview         scanSub.unsubscribe(); // stop scanning       });
     } else if (status.denied) {       // camera permission was permanently denied       // you must use QRScanner.openSettings() method to guide the user to the settings page       // then they can grant the permission from there     } else {       // permission was denied, but not permanently. You can ask for permission again at a later time.     }  })  .catch((e: any) => console.log('Error is', e));