【发布时间】:2021-08-01 22:28:51
【问题描述】:
我对 RNCamera 有疑问。它以前可以工作,但现在停止了,我不知道为什么。 问题是它没有被渲染,没有显示请求权限的弹出窗口,我可以在日志中看到这个错误:
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 是这样使用的:
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 版本是 0.63.2
react-native-camera 版本是 3.23.1
我尝试按照here 的描述使用手动安装,但收到模块链接两次的错误,我没有克服。
你能帮忙吗?如果您需要我可以提供的任何其他来源。
谢谢
编辑:
我发现了奇怪的事情。 RNCamera 在应用程序中的 2 个不同地方使用,有时它可以在 1 个地方工作,但从不会在其他地方工作,并出现描述的错误。
EDIT2:
我已经按照here 此处所述成功手动安装了 react-native-camera,并且还解决了 this 链接两次但结果相同的模块问题
【问题讨论】:
标签: android react-native react-native-camera