React native 如何在react本机应用程序中访问联系人列表
我正在开发一个完整的移动CRM,作为开发的一部分,我需要通过电话访问和修改联系人列表React native 如何在react本机应用程序中访问联系人列表,react-native,React Native,我正在开发一个完整的移动CRM,作为开发的一部分,我需要通过电话访问和修改联系人列表 哪一个插件是用于此目的的最佳插件?查看React Native Contacts,发现首先您需要安装React Native Contacts库。运行此命令npm install react native contacts--save 然后使用这个代码 import Contacts from 'react-native-contacts'; Contacts.getAll((err, contacts) =
哪一个插件是用于此目的的最佳插件?查看React Native Contacts,发现首先您需要安装React Native Contacts库。运行此命令
npm install react native contacts--save
然后使用这个代码
import Contacts from 'react-native-contacts';
Contacts.getAll((err, contacts) => {
if (err) {
throw err;
}
// contacts returned
})
要在
IOS
和android
上进行特定访问,请通过此链接如果您正在使用,则最好使用。我发现它非常容易使用。现在,他们有了api,可以根据提供的电话号码返回联系人,下面是一个示例
import Contacts from 'react-native-contacts';
const phoneNumber = "+92123456789"; //Number could be complete and it will search
//with all the numbers from the contacts
//database and will return results accordingly.
Contacts.getContactsByPhoneNumber(phoneNumber, (err, contacts) => {
if (err) {
console.log('some error happended ' + err);
} else {
// contact is javascript object and that can have more that one contacts details
console.log('Contact : ' + JSON.stringify(contacts));
}
});
更多详情可从这里获得