react-native-contacts 联系人通讯录

https://github.com/rt2zz/react-native-contacts

getAll(回调) - 将所有联系人作为对象数组返回
getAllWithoutPhotos- 与getAllAndroid 相同,但在iOS上,它不会返回用于联系人照片的uris(因为在创建图像时存在大量开销)
getPhotoForId(contactId, callback) - 为联系人照片返回URI(或null)
addContact (联系人,回叫) - 将联系人添加到地址簿。
openContactForm (联系人,回叫) - 创建一个新的联系人并在联系人UI中显示。
updateContact (contact,callback) - 联系人是具有有效recordID的对象
deleteContact (contact,callback) - 联系人是具有有效recordID的对象
getContactsMatchingString (string,callback) - 其中string是任何匹配名称(first,middle,family)的字符串
checkPermission(回调) - 仅检查访问联系人ios的权限
requestPermission(回叫) - 请求仅允许访问联系人ios的权限

Contacts.checkPermission((err, permission) => {
     if (err) throw err;
       if (permission == 'denied') {
            return Toast.info('您已拒绝了通讯录的访问权限,请前往设置打开',1)
        }
 // Contacts.PERMISSION_AUTHORIZED || Contacts.PERMISSION_UNDEFINED || Contacts.PERMISSION_DENIED
      if (permission == 'undefined') {
         Contacts.requestPermission((err, permission) => {
           if (permission == 'denied') {
              return Toast.info('您已拒绝了通讯录的访问权限,请前往设置打开',1);
            }
              if (permission == 'authorized') {
                  this.go2Page();
              }
        })
      }
      if (permission == 'authorized') {
         this.go2Page();
      }
})
Contacts.getAllWithoutPhotos((err, contacts) => {
     if (err) throw err;
     console.log(contacts)
})
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容