BarCodeScanner can't scan


#1

when i use BarCodeScanner ,the camera work ,but can’t scan info from qrcode.(ios can scan,android can’t) ,what happend?
my phone is Mi 5X

package.json and app.js as follow:

{
  "name": "ex1",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "react-native-scripts": "1.13.2",
    "jest-expo": "26.0.0",
    "react-test-renderer": "16.3.0-alpha.1"
  },
  "main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
  "scripts": {
    "start": "react-native-scripts start",
    "eject": "react-native-scripts eject",
    "android": "react-native-scripts android",
    "ios": "react-native-scripts ios",
    "test": "jest"
  },
  "jest": {
    "preset": "jest-expo"
  },
  "dependencies": {
    "expo": "26.0.0",
    "react": "16.3.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-26.0.0.tar.gz"
  }
}
export default class BarcodeScannerExample extends React.Component {
  state = {
    hasCameraPermission: null,
  }

  async componentWillMount() {
    const { status } = await Permissions.askAsync(Permissions.CAMERA);
    this.setState({hasCameraPermission: status === 'granted'});
    }

  render() {
    const { hasCameraPermission } = this.state;

    if (hasCameraPermission === null) {
      return <Text>Requesting for camera permission</Text>;
    } else if (hasCameraPermission === false) {
      return <Text>No access to camera</Text>;
    } else {
      return (
        <View style={{ flex: 1 }}>
          <BarCodeScanner
            onBarCodeRead={this._handleBarCodeRead}
            style={StyleSheet.absoluteFill}
          />
        </View>
      );
    }
  }

  _handleBarCodeRead = ({ type, data }) => {
    alert('Bar code with type ${type} and data ${data} has been scanned!');
  }
}

#2

Hey @songsong2. What QR code are you trying to scan? The BarCodeScanner is working on SDK 26 for me.


#3

I try to scan a url and a string,but i can’t get the result. my sdk version is 26.


#4

I have the same problem.

  • iPhones work well
  • Most Androids work well
  • Samsung A3, Android 7.0 will not trigger any code recognition
    • Neither Expo Client nor standalone APK’s trigger any recognition
    • However, the same phone does scan QR’s with other apps

Is anyone having the same problem?
Thank you


#5

Sorry,I did not visit this site recently.
Android 7.1.2 will not trigger any code recognition.I solve the problem with using sdk22.
Thank you.


closed #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.