如何从react-native中正确导入PermissionsAndroid?

时间:2018-05-30 11:22:19

标签: react-native react-native-android react-native-camera

我实际上是在尝试使用react-native-camera,但我在第14行遇到了错误:https://github.com/react-native-community/react-native-camera/blob/master/src/handlePermissions.js#L14其中

const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA, {
        title: permissionDialogTitle,
        message: permissionDialogMessage,
      });

我遇到的错误是:

Cannot read property 'request' of undefined
TypeError: Cannot read property 'request' of undefined

我怀疑它是导入PermissionsAndroid的方式:

import { PermissionsAndroid } from 'react-native';

PermissionsAndroidundefined。查看react-native.js,我无法在任何地方找到PermissionsAndroid。它被移动了吗?我在react-native-cli: 2.0.1

任何想法都赞赏。

0 个答案:

没有答案