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?
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#
- Capacitor
- Cordova
- Enterprise
$ npm install cordova-plugin-qrscanner $ npm install @ionic-native/qr-scanner $ ionic cap sync
$ ionic cordova plugin add cordova-plugin-qrscanner $ npm install @ionic-native/qr-scanner
Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us
#
Supported Platforms- Android
- Browser
- iOS
- Windows
#
CapacitorNot Compatible
#
Usage#
ReactLearn more about using Ionic Native components in React
#
Angularimport { 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));