QRScanner doesn't work


#1

This is my code:

scanValidate(){
  var qr = this.qrScanner;
  var scanResult: string;

  qr.prepare()
  .then((status: QRScannerStatus) => {
     if (status.authorized) {
      qr.scan().subscribe((res:string) => {
      qr.show()
      scanResult = res
      console.log(scanResult)
      qr.hide()
      }).unsubscribe();
  }
});

It start the camera on pc, I can see the light on, but on android the camera view doesn’t start and doesn’t work.

Console log:

[Deprecation] Unknown constraint named facingMode rejected
plugin.min.js:1983

URL.createObjectURL(stream) is deprecated! Use elem.srcObject = stream instead!
plugin.min.js:207

I’ve searched along the whole internet, but I can’t find solution that fits…


#2

What plugin you are using?

I’m using the below plugin and it is working fine for me

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

Refer this : https://ionicframework.com/docs/native/barcode-scanner/


#3

This is barcode scanner but I need to read qr code… Thanks!!


#4

But it also scans QR Code. Just check “BarcodeScanResult” tab - format: ‘QR_CODE’.


#5

It scans QR Code too. Just give a try


#6

Oh, I’d lost this function… Thanks!! I’ll try and post if it works :ok_hand:t2:


#7

The Barcode scanner reads qr codes any many other types too.
Also: It’s way easier to implement and provides a much better user experience out of the box.

In my opinion, the qr-code scanner plugin should be removed from the docs.


#8

I’m agree with that. Barcode Scanner it’s too easy and well documented plugin and it’s confuse 2 plugins doing same task… the storage plugin anoyed me too