2

I am developing a web app with react native for web, and I want to scan qrcode but it does not work, without errors.

I put the codes on snack, ran it on mobile with Expo Go, it worked perfectly. However, when I published it on github web, and open it with mobile browser (iOS Safari), the camera worked normally, but no qrcode was read (just no reponse when I put a qrcode inside).

Code info: I referred sample code on expo-camera and expo-barcode-scanner. Since expo-barcode-scanner does not support web, I imported expo-camera only.

Version info:

  • "expo": "~42.0.1"
  • "expo-camera": "~11.2.2"
  • "expo-status-bar": "~1.0.4"
  • "react": "16.13.1"
  • "react-dom": "16.13.1"
  • "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz"
  • "react-native-web": "~0.13.12"

Also, I checked this issue, and tried the followings:

  1. open /node_modules/expo-camera/package.json, set "@koale/useworker" to "4.0.1"
  2. run npm i under root dir
  3. open /node_modules/expo-camera/node_modules/@koale/useworker/package.json, confirmed that the version is 4.0.1

But it still did not work.

I feel confused now, did I take wrong solutions? Is there any workarounds?

Any suggestions would be appreciated.

UotaniSayo
  • 38
  • 4

1 Answers1

0

When scanning QR code, the barCodeScannerSetting is required. Like this:

barCodeScannerSettings={{ barCodeTypes: [BarCodeScanner.Constants.BarCodeType.qr], }}
starball
  • 20,030
  • 7
  • 43
  • 238
UotaniSayo
  • 38
  • 4