LetynSOFT
LetynSOFT

Reputation: 253

Barcode scanning issues on iPhones

We are having issues on some iPhones with scanning barcodes using the ZBarSDK package (https://cocoapods.org/pods/ZBarSDK). It appears the issue is coming from newer phone types (iPhone 13, iPhone 13 Pro etc). Based on this, and on one screenshot from a client, where the app is unable to focus on the barcode, we think this is caused by the phone having multiple cameras on the back and choosing an inappropriate camera.

Unfortunately, this happens only to some of our clients and we cannot replicate this in any device we have in our hands.

The code that shows the barcode scanner is as follows (slightly simplified):

 func showCaptureBarcode(completion: @escaping(String?) -> Void) {
    let zbar = ZBarReaderViewController.init()
    let del = ZbarDelegate.init { [weak zbar] str in
      zbar?.dismiss(animated: true) {
      }
      self.zbarDelegate = nil
      completion(str)
    }
    zbar.cameraDevice = .rear
    zbar.readerDelegate = del
    self.zbarDelegate = del
    self.topView().present(zbar, animated: true) {
      if zbar.readerView.device.isFocusModeSupported(.continuousAutoFocus) {
        zbar.readerView.device.focusMode = .continuousAutoFocus
      } else if zbar.readerView.device.isFocusModeSupported(.autoFocus) {
        zbar.readerView.device.focusMode = .autoFocus
      }
      if zbar.readerView.device.isExposureModeSupported(.continuousAutoExposure) {
        zbar.readerView.device.exposureMode = .continuousAutoExposure
      } else if zbar.readerView.device.isExposureModeSupported(.autoExpose) {
        zbar.readerView.device.exposureMode = .autoExpose
      }
    }
  }

Is there a simple way to make the ZBarReaderViewController focus correctly, do we need to find the correct device in our code, or do we need to add all the controls the Photo app has and let users focus/zoom manually? The barcodes are not usually that big/far away.

FYI: The app is called Nest Forms - Survey builder.

Upvotes: 2

Views: 161

Answers (0)

Related Questions