capacitor-community / barcode-scanner

A fast and efficient (QR) barcode scanner for Capacitor
MIT License
437 stars 167 forks source link

Error checkPermission() was not implemented by android #277

Open kacangdankawan opened 1 year ago

kacangdankawan commented 1 year ago

I also having the same problem when running on android studio

[Barcode Scanner error: Error: BarcodeScanner.checkPermission() is not implemented on android]

here is my implementation,

    methods: {
        async startScan() {
        try {
            // Check camera permission
            await BarcodeScanner.checkPermission({ force: true });

            // Make background of WebView transparent
            BarcodeScanner.hideBackground();

            const result = await BarcodeScanner.startScan();

            // If the result has content
            if (result.hasContent) {
            console.log(result.content);
            // You can process the scanned content as per your requirements
            // For example, you can display it on the screen or send it to a server.
            }
        } catch (error) {
            console.error("Barcode Scanner error:", error);
        }
    },

However , it works well on webview via ionic serve. The camera get accessed smoothly and scan work nicely.

*I have disable the checkPermission() line , but it comes out with new error for scan

Sending plugin error: {"save":false,"callbackId":"4461136","pluginId":"BarcodeScanner","methodName":"startScan","success":false,"error":{"message":"Attempt to invoke virtual method 'void androidx.camera.view.PreviewView.setScaleType(androidx.camera.view.PreviewView$ScaleType)' on a null object reference"}}

rateltechcom commented 1 year ago

I have same problem. Are there any solutions?

mrivera24 commented 12 months ago

I have a similar problem. In android doesnt request the permissions, is deny by default. Any solution? Thanks