打开控制台安装contacts插件
ionic cordova plugin add cordova-plugin-contacts
npm install @ionic-native/contacts
app.module.ts引入import { Contacts } from '@ionic-native/contacts';
providers: [ Contacts ]
contact-list.ts引入import { Contacts } from '@ionic-native/contacts';
constructor(private contacts: Contacts) {
}
查找通讯录全部联系人:
this.contacts.find(['displayName', 'phoneNumbers'], {filter: "", multiple: true})
.then(contacts => {
console.log(contacts);
this.allContacts=contacts;
});
点击选择单个联系人:
this.contacts.pickContact().then((contact)=>{
console.log("contacts:-->"+ JSON.stringify(contact));
this.familyDisplayName = contact.displayName;
this.familyPhoneNumbers = contact.phoneNumbers[0].value;
});