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!');
}
}