I need the following feature: When a user clicks on the contacts button, they should be able to view all contacts from their device who are currently using the app. Additionally, they should see an "invite" option for contacts who are not yet using the app.
How can I achieve this? I have already installed the contacts Cordova plugin. What steps should I take next; should I implement a filter to identify which contacts on the device are using the same app? I am using the Ionic 2 Framework.
Here is my code snippet:
HOME.TS
findContact(ev: any) {
let fields: ContactFieldType[] = ['displayName'];
const options = new ContactFindOptions();
options.filter = ev.target.value;
options.multiple = true;
options.hasPhoneNumber = true;
Contacts.find(fields, options).then((contacts) => {
this.contactsfound = contacts;
console.log(JSON.stringify(contacts[0]));
});
if (this.contactsfound.length == 0) {
this.contactsfound.push({
displayName: 'No Contacts found'
});
}
this.search = true;
}
Home.HTML
<ion-content>
<ion-searchbar (ionInput)="findContact($event)" placeholder="Enter display name"></ion-searchbar>
<ion-list [hidden]="!search">
<ion-item *ngFor="let item of contactsfound">{{item.displayName}}</ion-item>
</ion-list>
</ion-content>