expo: [expo-camera] [iOS] onBarcodeScanned is never called on iOS with Expo Go
Minimal reproducible example
https://github.com/jcxldn/expo-sdk50-cam-qr-repro
Summary
When using Expo Go (client version 1017593) on my iOS 17.2.1 device with this minimal reproduction project, the camera loads up and appears to work as normal but onBarcodeScanned is never called even if a valid QR code is in focus and in frame. I have not been able to test this on a production build.
Environment
expo-env-info 1.2.0 environment info:
System:
OS: Linux 6.6 Manjaro Linux
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 21.5.0 - /usr/bin/node
Yarn: 1.22.21 - /usr/bin/yarn
npm: 10.3.0 - /usr/bin/npm
npmPackages:
expo: ~50.0.3 => 50.0.3
react: 18.2.0 => 18.2.0
react-native: 0.73.2 => 0.73.2
npmGlobalPackages:
eas-cli: 7.0.0
Expo Workflow: managed
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Reactions: 2
- Comments: 17 (1 by maintainers)
I think they changed the prop name It’s now
onBarcodeScannedinstead ofonBarCodeScanned(no uppercase ‘C’ on ‘code’)Also,
barCodeScannerSettingsbecomesbarcodeScannerSettingsBut
barCodeTypesremains the sameThis solution worked for me! 😃
According to the doc, the prop remains as
onBarCodeScanned@obviouswhy Thanks! Indeed it was due to that barCodeTypes enum not working properly.
FYI to anyone with the same issue, since I’m using typescript I had to handle the type within the callback function:
Seems like for iOS the
barCodeTypes: ["qr"]part is not recognizing the enum of the type for iOS correctly. I was able to triggeronBarcodeScannedby setting barCodeTypes toBarCodeScanner.Constants.BarCodeType.qror"org.iso.QRCode"(which is the value of BarCodeScanner.Constants.BarCodeType.qr).It would look something like:
Has anyone solved this issue? Same with me for
onBarcodeScanned doesn’t fire anything…
My apologies, I got a little mixed up here. It seems to be
onBarcodeScannedforexpo-camera/nextandonBarCodeScannedforexpo-camera. I tried both expo-camera and expo-camera/next on my own and had the same issue, but this minimal repro is for expo-camera.