question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

startScan() doesn't open native camera

See original GitHub issue

Describe the bug I installed this plugin on Ionic 5 Angular iOS project. Whenever I run startScan method, it doesn’t trigger native camera and no error message. The only thing I can see in log is this

⚡️  To Native ->  BarcodeScanner hideBackground 7747052
⚡️  To Native ->  BarcodeScanner startScan 7747053

To Reproduce Steps to reproduce the behavior:

  1. Follow install plugin instruction at readme

  2. Import Plugins import { Plugins } from '@capacitor/core';

  3. Put prepare on ionViewWillEnter()

  4. Create wrapper function to call startScan method.

async openBarcodeScanner() {
    const { BarcodeScanner } = Plugins;
    
    BarcodeScanner.hideBackground();
    try {
      const barcodeData = await BarcodeScanner.startScan()
        console.log('Barcode data', barcodeData);
        if(barcodeData.hasContent) {
          this.checkBarcode(barcodeData.content);
        }
    } catch (err) {
      console.log('Scan barcode error', err);
    }
  } 

  1. Edit info.plist, set camera usage description
  2. Ionic build, sync, then open ios

Expected behavior When startScan method get called, screen should immediately navigate to native camera.

Smartphone (please complete the following information):

  • Device: iPhone 6
  • OS: iOS 12.4.9

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
tafelnlcommented, Dec 16, 2020

@eryzerz @bash88 @herefishyfish

I am delighted to announce that I just released a version with permission utils added.

You can install it by running:

npm install @dutchconcepts/capacitor-barcode-scanner@latest
npx cap sync

Documentation can be found here: https://github.com/DutchConcepts/capacitor-barcode-scanner/tree/main#permissions

I am inviting you guys to test it out and share some feedback

1reaction
tafelnlcommented, Nov 24, 2020

Hm, I see now. Hold on tight as I will release a solution for this in a couple of days. In the meantime you could request permission with this plugin for example: https://www.npmjs.com/package/capacitor-plugin-permissions

Read more comments on GitHub >

github_iconTop Results From Across the Web

QR Scanner: Seems to be working in the background, but ...
The QR Scanner seems to be working in the background but doesn't display a preview when calling show(). The code for the QR...
Read more >
Android - Why am I getting a black camera screen?
If you are running an Android app on a device and the camera screen is black or it ... Check that the startScanning()...
Read more >
BluetoothLeScanner - Android Developers
Use BluetoothAdapter#getBluetoothLeScanner() to get an instance of BluetoothLeScanner . ... it has to be the same instance as the one used to start...
Read more >
@capacitor-community/barcode-scanner - npm
After startScan() is resolved, the Scanner View will be automatically destroyed to save battery. But if you want to cancel the scan before ......
Read more >
Native Camera returned opening error "Cannot Initialise ...
1. If, after reboot, you sometimes cannot connect the default camera app to front camera, this is most likely a hardware problem. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found