无法获取Android权限对话框以针对React Native

时间:2018-07-31 13:06:02

标签: android react-native android-permissions

我正在使用react-native-permissions,起初我以为是RN版本问题,所以我将库版本为0.540.52降级到1.1.1。我试图将代码放入各种生命周期组件中,例如componmentDidMount()componentDidUpdate()

    _requestPermission = (reqFor) => {
          Permissions.request(reqFor).then(response => {
          })
      }

  _AskForPermissions = () => {
          Permissions.checkMultiple(['camera', 'photo', 'storage', 'location']).then(response => {
              //console.log(response.camera);
              if (response.camera != 'authorized') {
                  this._requestPermission('camera')
              }

              if (response.photo != 'authorized') {
                  this._requestPermission('photo')
              }

              if (response.storage != 'authorized') {
                  this._requestPermission('storage')
              }

              if (response.location != 'authorized') {
                  this._requestPermission('location')
              }
          })
      }

我在manifest中也设置了权限,但是要注意的是,当我执行react-native link react-native-permissions时,它仅链接到iOS而不是Android。那可能是问题所在吗?

0 个答案:

没有答案