React native camera fails to render

Viewed 397

I have a problem with RNCamera. It was working before but stopped now and I am not sure why. Problem is that it is not rendered, pop up to request permission is not shown and I can see this error in logs:

Possible Unhandled Promise Rejection (id: 3):
TypeError: CameraManager.checkVideoAuthorizationStatus is not a function
TypeError: CameraManager.checkVideoAuthorizationStatus is not a function
    at requestPermissions$ (/home/pro/Documents/app/.vscode/.react/index.bundle:143969:61)
    at tryCatch (/home/pro/Documents/app/.vscode/.react/index.bundle:25021:19)
    at Generator.invoke [as _invoke] (/home/pro/Documents/app/.vscode/.react/index.bundle:25194:24)
    at Generator.next (/home/pro/Documents/app/.vscode/.react/index.bundle:25064:23)
    at tryCatch (/home/pro/Documents/app/.vscode/.react/index.bundle:25021:19)
    at invoke (/home/pro/Documents/app/.vscode/.react/index.bundle:25094:22)
    at /home/pro/Documents/app/.vscode/.react/index.bundle:25124:13
    at tryCallTwo (/home/pro/Documents/app/.vscode/.react/index.bundle:27110:7)
    at doResolve (/home/pro/Documents/app/.vscode/.react/index.bundle:27274:15)
    at new Promise (/home/pro/Documents/app/.vscode/.react/index.bundle:27133:5)

RNCamera is used like this:

import { RNCamera } from 'react-native-camera';
...
<RNCamera
  style={{ flex: 1 }}
  captureAudio={false}
  ref={(cam) => {
    this.camera = cam;
  }}
  barCodeTypes={[
    RNCamera.Constants.BarCodeType.aztec,
    RNCamera.Constants.BarCodeType.qr,
    RNCamera.Constants.BarCodeType.datamatrix,
  ]}
  onBarCodeRead={this.onSuccessQrScan}
  notAuthorizedView={
    <View style={StylesGlobal.container}>
      <Icon name="close" size={60} color={Color.RED} style={{ alignSelf: 'center' }} />
      <TextCenter small>{strings.general.cameraNotAuthorized}</TextCenter>
    </View>
  }
  androidCameraPermissionOptions={{
    title: strings.general.cameraPermissionTitle,
    message: strings.general.cameraPermission,
    buttonPositive: strings.general.ok,
    buttonNegative: strings.general.cancel,
  }}
/>
...

react-native version is 0.63.2

react-native-camera version is 3.23.1

I tried to use manual installation as described here but got error that module was linked twice which i did not overcome.

Can you help please. If you need any other source I can provide.

Thanks

EDIT:

I have discovered strange thing. RNCamera is used in 2 different places in app and sometimes it works on 1 but never on other with described error.

EDIT2:

I have successfully manuaaly installed react-native-camera as described here here and also solved problem with module linked twice by this but with same result

1 Answers

I think react-native link react-native-camera doesn't work as expected. Manually linking library will solve the problem. And for your error - module was linked twice - first unlink everything related to react-native-camera and add manual linking again using the docs.

Related