https://github.com/rt2zz/react-native-contacts
getAll(回調(diào)) - 將所有聯(lián)系人作為對(duì)象數(shù)組返回
getAllWithoutPhotos- 與getAllAndroid 相同,但在iOS上,它不會(huì)返回用于聯(lián)系人照片的uris(因?yàn)樵趧?chuàng)建圖像時(shí)存在大量開銷)
getPhotoForId(contactId, callback) - 為聯(lián)系人照片返回URI(或null)
addContact (聯(lián)系人沉帮,回叫) - 將聯(lián)系人添加到地址簿侥衬。
openContactForm (聯(lián)系人,回叫) - 創(chuàng)建一個(gè)新的聯(lián)系人并在聯(lián)系人UI中顯示荞雏。
updateContact (contact猜欺,callback) - 聯(lián)系人是具有有效recordID的對(duì)象
deleteContact (contact箱玷,callback) - 聯(lián)系人是具有有效recordID的對(duì)象
getContactsMatchingString (string,callback) - 其中string是任何匹配名稱(first絮吵,middle弧烤,family)的字符串
checkPermission(回調(diào)) - 僅檢查訪問聯(lián)系人ios的權(quán)限
requestPermission(回叫) - 請(qǐng)求僅允許訪問聯(lián)系人ios的權(quán)限
Contacts.checkPermission((err, permission) => {
if (err) throw err;
if (permission == 'denied') {
return Toast.info('您已拒絕了通訊錄的訪問權(quán)限,請(qǐng)前往設(shè)置打開',1)
}
// Contacts.PERMISSION_AUTHORIZED || Contacts.PERMISSION_UNDEFINED || Contacts.PERMISSION_DENIED
if (permission == 'undefined') {
Contacts.requestPermission((err, permission) => {
if (permission == 'denied') {
return Toast.info('您已拒絕了通訊錄的訪問權(quán)限蹬敲,請(qǐng)前往設(shè)置打開',1);
}
if (permission == 'authorized') {
this.go2Page();
}
})
}
if (permission == 'authorized') {
this.go2Page();
}
})
Contacts.getAllWithoutPhotos((err, contacts) => {
if (err) throw err;
console.log(contacts)
})