Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hint option of scanBarcode method is not applied #17

Open
ToKruAmApp opened this issue Aug 1, 2024 · 2 comments
Open

Hint option of scanBarcode method is not applied #17

ToKruAmApp opened this issue Aug 1, 2024 · 2 comments

Comments

@ToKruAmApp
Copy link

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
Copy link

rufusbarnes commented Nov 5, 2024

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.

EDIT:
Obviously as a capacitor plugin the implementations vary by platform. I didn't think to check but each platform actually uses different subsets of the options, which isn't included in the docs. The swift implementation uses the instructions , button text, camera direction and device orientation as seen below:

let scannedBarcode = try await manager.scanBarcode(with: scanArguments.scanInstructions, 
                                                   scanArguments.scanButtonText, 
                                                   scanArguments.cameraDirection, 
                                                   and: scanArguments.scanOrientation)

and the android:

val parameters = OSBARCScanParameters(
                   scanInstructions = scanInstructions,
                   cameraDirection = cameraDirection,
                   scanOrientation = scanOrientation,
                   scanButton = scanButton!!,
                   scanText = scanText!!,
                   hint = hint,
                   androidScanningLibrary = androidScanningLibrary
)

This gives me the impression that it would be very difficult to have a shared experience cross platform if using this plugin, as the iOS and Web implementations are pretty barebones in comparison.

@abennouna
Copy link

Indeed, we provide hint: CapacitorBarcodeScannerTypeHint.QR_CODE and nevertheless, it's able to scan 1D barcodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants