反应本机。无法在Android上获取联系人列表

时间:2019-04-02 09:24:31

标签: javascript react-native-android

我添加了<uses-permission android:name="android.permission.READ_CONTACTS" />进行显示,然后使用https://facebook.github.io/react-native/docs/permissionsandroid。 而且对我不起作用。但另一个权限(如位置)有效。有什么想法吗?

async requestContactsPermission() {
try {
  const granted = await PermissionsAndroid.request(
    PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
    {
      title: 'test',
      message: 'message',
      buttonNeutral: 'Ask Me Later',
      buttonNegative: 'Cancel',
      buttonPositive: 'OK',
    },
  );
  if (granted === PermissionsAndroid.RESULTS.GRANTED) {
    console.log('You can use the contacts');
  } else {
    // always denied
    console.log('Contacts permission denied');
  }
} catch (err) {
  console.warn(err);
}


async componentWillMount() {
  await requestContactsPermission();
}

我在清单中的权限

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-feature android:name="android.hardware.camera" android:required="true"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />

...

0 个答案:

没有答案