ionic-team / capacitor-barcode-scanner

https://capacitorjs.com/docs/apis/barcode-scanner
MIT License
11 stars 7 forks source link

Hint option of scanBarcode method is not applied #17

Open ToKruAmApp opened 3 months ago

ToKruAmApp commented 3 months ago

Calling the scanBarcode method with a hint to specify the type of barcode to be scanned doesn't seem to work. Calling scanBarcode({ hint: 1 }) for example should only allow AZTEC codes but somehow QR codes still get detected.

rufusbarnes commented 14 hours ago

I think this is true for the majority of the configurable options. The scanBarcode() method implementation uses options to setup an object param = {...} which is a similar object but with some default values applied. Here's a snippet:

const param = {
    facingMode: options.cameraDirection === 1 ? 'environment' : 'user',
    hasScannerButton: false,
    scanButton: options.scanButton === undefined ? false : options.scanButton,
    ...
}

It looks like the only places param's fields are used are:

  1. To set the fps of Html5QrcodeConfig when calling window.OSBarcodeWebScanner.start(...)
  2. To set the facing mode when calling window.OSBarcodeWebScanner.start(...)

No other options have an effect on the execution of the method.