反应本机AndroidPermission不授予权限

时间:2020-07-06 12:11:38

标签: react-native

嘿,我正在使用react native项目,我需要访问我使用的移动电话的IMIE react-native-imei一切都很好,但是权限未在此处授予我的功能的问题

getImie = async () => {
    if (Platform.OS === 'android') {
      try {
        const granted = await PermissionsAndroid.request(
          PermissionsAndroid.PERMISSIONS.READ_PHONE_STATE,
          {
            title: 'Phone State Permission',
            message:
              'the application needs to access to your phone state to take the IMIE',
            buttonNeutral: 'Ask Me Later',
            buttonNegative: 'Cancel',
            buttonPositive: 'OK',
          },
        );
        if (granted === PermissionsAndroid.RESULTS.GRANTED) {
          IMEI.getImei().then(imeiList => {
            if (imeiList.length > 0) {
              this.setState({imie: imeiList[0], foundimei: true});
            }
          });
        } else {
          console.log('Phone State permission denied');
        }
      } catch (err) {
        console.warn(err);
      }
    }
  };


我的问题是const授予它为空字符串,因此get imie函数无法正常工作,另一疯狂的地方是我要求提供电话状态,但许可是关于像波纹管这样的电话

enter image description here

那么有人能给我任何想法吗?

0 个答案:

没有答案