Difference between Camera and BarcodeScanner?

Do they work exactly the same or are there any benefits by using BarcodeScanner?

I needed to get the ref to take a picture via barcodeScanner and
ref={ ref => this.camera = ref } doesn’t work for this.camera.takePictureAsync, So Instead I used Camera component where it works fine.

In our documentation it specifies:

BarCodeScanner
A React component that renders a viewfinder for the device’s either front or back camera viewfinder and will detect bar codes that show up in the frame. BarCodeScanner uses Camera underneath so any Camera prop or method can be used when using BarCodeScanner.

But you need to specify Permissions.CAMERA which is the only caveat.

Which you can do by following this example:

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

If it doesn’t work within these bounds, then we may a bug with our code. The best way to help us in that case is to provide us a snack https://snack.expo.io

I hope this helps :slight_smile:

1 Like

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