我想在我的 AVD 上显示联系人列表,但我遇到了一个错误(我尝试链接包但它什么也没做):
我的代码:
const [contact, setContact] = useState([]);
useEffect(() => {
PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.READ_CONTACTS,
{
'title': 'Contacts',
'message': 'This app would like to view your contacts.'
}
).then(() => {
Contacts.getAll((err, contacts) => {
if (err === 'denied'){
// error
} else {
// contacts returned in Array
setContact(contacts);
console.log(contact);
}
})
})
.catch((err)=> {
console.log(err);
})
}, []);
### 错误 :
我到处寻找解决方案,但没有任何关于这个问题的信息,感谢您提前帮助我。
使用更新的 API 版本,您需要将回调语法更改为 promise .then 和 .catch,例如