Search code examples
react-nativeqr-codebarcode-scannerreact-native-camera

React Native Camera Barcode Types


I'm trying to use react-native-camera@0.4.1 (with react-native@0.39.2) to create a QR code scanner. The relevant essentials of my render() method are:

<Camera 
  aspect={Camera.constants.Aspect.fill}
  onBarCodeRead={(data) => console.log(data)} 
  barCodeTypes={['qr']}>
</Camera>

Without the barCodeTypes prop, everything works as expected. But once I include it, the view does not render, and I get the following error message:

*** -[AVCaptureMetadataOutput setMetadataObjectTypes:] Unsupported type found
    - use -availableMetadataObjectTypes

I'm guessing that I just need to write my ['qr'] argument in some other and correct way, but I'm not able to find any information in the documentation.


Solution

  • Ok, so I found another post on Stack Overflow that helped me figure out the availableMetadataObjectTypes. So to fix my particular problem, I'll just be changing barCodeTypes={['qr']} to barCodeTypes={['org.iso.QRCode']}.