QR Scanner


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


Ionic 扫码 QR Scanner插件的安装(Installation)

ionic cordova plugin add cordova-plugin-qrscanner npm install @ionic-native/qr-scanner

Ionic 扫码 QR Scanner插件支持的平台(Supported Platforms)

  • Android
  • Browser
  • iOS
  • Windows

Ionic 扫码 QR Scanner插件的用法(Usage)

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

constructor(private qrScanner: QRScanner) { }


// Optionally request the permission early
  .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));