android - react-native-contacts getAll 返回 null
问题描述
根据此链接,我使用 react-native-contact 在 android 设备中打开联系人列表,以便用户可以选择一个并将其添加到列表中。但是当我单击按钮打开联系人列表时,react-native-contacts getAll 返回 null。这是我使用的代码:
openContactlist() {
Contacts.getAll((err, contacts) => {
if (err) {
// throw err;
alert("NO");
}
// contacts returned
alert("yes");
})
}
在反应本机代码的渲染中,有一个按钮,通过单击它可以调用上面的函数:
<Button
title="From contact list"
onPress={this.openContactlist}
/>
错误:
null is not an object (evaluating '_react-native-contacts.getall')
解决方案
一个原因可能是您没有正确链接 react-native-contact
您还必须按照以下步骤链接 -
对于 Android: https ://github.com/rt2zz/react-native-contacts#android
推荐阅读
- google-apps-script - 将 Google 表格选项卡的几列下载到单独的文本文件中的脚本
- mysql - What is the difference between these two SQL function?
- reactjs - 您通常如何使用后端实现 react paypal
- jquery - Inject HTML using jQuery closest() and Ajax
- wicket - Wicket-9:如何防止 web-container 重启后 session 中存储的数据被清除?
- python - 将路径中的所有 csv 文件读取为 pandas 数据框
- php - POST-ing HTMLFormElements as Array 保持 DOM 顺序跨浏览器
- apache-kafka - kafka压缩率平均是什么意思
- python - AttributeError:“MetaDict”对象没有属性“get_field”django_elasticsearch
- html - 为什么 HTML 无序列表不会嵌套并与主项目符号保持在同一位置