Deen
Deen

Reputation: 621

How to get all contacts from Contact plugin in phonegap

I'm using Contact plugin in phonegap by following code

var options = new ContactFindOptions();
    var options = {
        multiple:true
    }
    options.multiple = true;
    var fields = ["displayName","phoneNumbers"];
    navigator.contacts.find(fields, onSuccessContact, onErrorContact, options);

Here, im getting the contacts who are displayName is null.

I dont want this type of filter. I want to get all the contacts from this plugin. How can i change the filter.

Upvotes: 1

Views: 4279

Answers (2)

user3255670
user3255670

Reputation:

var options      = new ContactFindOptions();
options.filter   = "";
options.multiple = true;

The Contacts Plugin is poorly documented. My notes are here:

http://codesnippets.altervista.org/documentation/phonegap/plugins/navigator.contacts.docs.html

Working App Here:

http://codesnippets.altervista.org/examples/phonegap/demos/PUBLIC.Apps.html

Upvotes: 1

Tim
Tim

Reputation: 98

There are some contact properties for this plugin, for example you can use id, name, nickname. Here the documentation where you can find it: http://docs.phonegap.com/en/edge/cordova_contacts_contacts.md.html

For example:

options.multiple = true;
var fields = ["nickName","phoneNumbers"];
navigator.contacts.find(fields, onSuccessContact, onErrorContact, options);

And a example with a options filter:

options.multiple = true;
var fields = ["nickName","phoneNumbers"];
options.filter   = "Robert";
navigator.contacts.find(fields, onSuccessContact, onErrorContact, options);

I hope you find them useful.

Upvotes: 0

Related Questions