capacitor-community / barcode-scanner

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

iOS barcode scanner error #287

Closed inandenizbal closed 1 year ago

inandenizbal commented 1 year ago

Hello, I've done the everything as its written and it was working a few days ago. Now when I try to make scan I can't do it.

Here is my code

import { Component, OnInit } from "@angular/core";
import { NavController } from "@ionic/angular";
import { BarcodeScanner } from "@capacitor-community/barcode-scanner";
import { ScooterDataService } from "../services/scooter-data.service";

@Component({
  selector: "app-qr-scan",
  templateUrl: "./qr-scan.page.html",
  styleUrls: ["./qr-scan.page.scss"],
})
export class QrScanPage implements OnInit {
  constructor(
    private route: NavController,
    private scooterService: ScooterDataService
  ) {}

  ngOnInit() {
    this.startScan();
  }
  async startScan() {
    await BarcodeScanner.checkPermission({ force: true });
    BarcodeScanner.hideBackground();

    const result = await BarcodeScanner.startScan(); // start scanning and wait for a result

    if (result.hasContent) {
      console.log(result.content); // log the raw scanned content
      this.scooterService.addServerQr(result.content);
      this.stopScan();
      this.route.navigateRoot(["./unlocking"]);
    }
  }
  stopScan() {
    BarcodeScanner.showBackground();
    BarcodeScanner.stopScan();
    document.querySelector("body").classList.remove("scanner-active");
  }
}

here is ios Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>CFBundleDevelopmentRegion</key>
        <string>en</string>
        <key>CFBundleDisplayName</key>
        <string>Electra</string>
        <key>CFBundleExecutable</key>
        <string>$(EXECUTABLE_NAME)</string>
        <key>CFBundleIdentifier</key>
        <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
        <key>CFBundleInfoDictionaryVersion</key>
        <string>6.0</string>
        <key>CFBundleName</key>
        <string>$(PRODUCT_NAME)</string>
        <key>CFBundlePackageType</key>
        <string>APPL</string>
        <key>CFBundleShortVersionString</key>
        <string>$(MARKETING_VERSION)</string>
        <key>CFBundleVersion</key>
        <string>$(CURRENT_PROJECT_VERSION)</string>
        <key>LSRequiresIPhoneOS</key>
        <true />
        <key>UILaunchStoryboardName</key>
        <string>LaunchScreen</string>
        <key>UIMainStoryboardFile</key>
        <string>Main</string>
        <key>UIRequiredDeviceCapabilities</key>
        <array>
            <string>armv7</string>
        </array>
        <key>UISupportedInterfaceOrientations</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UISupportedInterfaceOrientations~ipad</key>
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
            <string>UIInterfaceOrientationLandscapeLeft</string>
            <string>UIInterfaceOrientationLandscapeRight</string>
        </array>
        <key>UIViewControllerBasedStatusBarAppearance</key>
        <true />
        <key>NSLocationWhenInUseUsageDescription</key>
        <string>Uygulamanın konumunu kullanabilmesi için izin vermeniz gerekmektedir.</string>

    </dict>
</plist>`

And here is the error

⚡️  [error] - ERROR Error: Uncaught (in promise): Error: "BarcodeScanner.checkPermission()" is not implemented on ios
CapacitorException@capacitor://localhost/default-node_modules_capacitor_core_dist_index_js.js:125:10
@capacitor://localhost/default-node_modules_capacitor_core_dist_index_js.js:263:41
onInvoke@capacitor://localhost/vendor.js:80931:39
@capacitor://localhost/polyfills.js:271:53
@capacitor://localhost/polyfills.js:1428:41
onInvokeTask@capacitor://localhost/vendor.js:80918:43
@capacitor://localhost/polyfills.js:316:61
drainMicroTaskQueue@capacitor://localhost/polyfills.js:734:46
@capacitor://localhost/polyfills.js:631:44
invokeTask@capacitor://localhost/polyfills.js:1829:28
globalCallback@capacitor://localhost/polyfills.js:1860:41
⚡️  To Native ->  CapacitorGoogleMaps onResize 53707492
⚡️  TO JS undefined

I am using the latest version I guess, I searched on internet but I couldn't find the solution. Can you please help me?

ramzanrozali commented 1 year ago

Hi how do you fix this?

inandenizbal commented 12 months ago

Uninstall the mlkit scanner, I don't know how it installed but it was the source of this problem