Skip to content Skip to sidebar Skip to footer

Listing Phone Contacts Using Javascript

Im developing a multi-platform app for android, ios and windows using simple html, css, js and condova however I find it challenging, as simple as it may sound, to display all the

Solution 1:

From Cordova 3 even “core” APIs are outside of the core (cordova.js).

So you need to first install the contacts plugin and then add the code for list them. If you want to only select a contact, you could use the pick contact function, that opens the native contact picker and return the selected contact object.

Get all contacts from phone

functiononSuccess(contacts) {
    console.log('Found ' + contacts.length + ' contacts.');
    // here you can manipulate the contacts arrayconsole.log(contacts);
};

functiononError(contactError) {
    console.log('Error: '+contactError);
};

// list all contactsvar options      = newContactFindOptions();
options.filter   = "";
options.multiple = true;
var fields = [navigator.contacts.fieldType.displayName, navigator.contacts.fieldType.name];
navigator.contacts.find(fields, onSuccess, onError, options);

Post a Comment for "Listing Phone Contacts Using Javascript"