开发者

how to retrieve contact details from iphone using id using contacts.find in phonegap

开发者 https://www.devze.com 2023-02-28 19:19 出处:网络
My task is to retrieve contact details using specific id. I am using below functionality where i am retrieving viewId from another page. here, Contact Listing page is index.html and when user will cl

My task is to retrieve contact details using specific id.

I am using below functionality where i am retrieving viewId from another page. here, Contact Listing page is index.html and when user will click on view icon, it will get redirected to viewContact.html where i have put below code to retrieve contact details.

Now main problem i am facing is if i will use below code then it will search for id in below all fields. but i want to search only in id field. so that i can get perfect result.

          //this is viewContact.html
    var options = new ContactFindOptions();
    options.filter= viewId; // getting from index.html 
 开发者_Python百科   options.multiple=false;
    //options.filter = 23;//testing with static id
    var fields = ["id","name", "phoneNumbers", "emails", "photos"];

//here i cannot use only id in fields, otherwise it will not allow me to display whole content of contact list.

Please give me solution in phonegap.

    navigator.service.contacts.find(fields, onSuccess, onError, options);


In your contactSuccess function you can through the list checking if the field "id" is the correct. For example

for (var c=0;c<contacts.length;c++) {
   if (contacts[c].id == viewId) {
    // contact found
    break;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消