【问题标题】:how to retrieve contact details from iphone using id using contacts.find in phonegap如何使用 id 在 phonegap 中使用 contacts.find 从 iphone 检索联系人详细信息
【发布时间】:2011-04-27 06:43:24
【问题描述】:

我的任务是使用特定 ID 检索联系人详细信息。

我正在使用以下功能从另一个页面检索 viewId。在这里,联系人列表页面是 index.html,当用户单击查看图标时,它将被重定向到 viewContact.html,我在其中放置了以下代码以检索联系人详细信息。

现在我面临的主要问题是,如果我将使用下面的代码,那么它将在所有字段下方搜索 id。但我只想在 id 字段中搜索。这样我才能得到完美的结果。

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

//这里我不能在字段中只使用id,否则将无法显示联系人列表的全部内容。

请在phonegap中给我解决方案。

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

【问题讨论】:

    标签: web-applications cordova contact


    【解决方案1】:

    在您的contactSuccess 函数中,您可以通过列表检查字段“id”是否正确。例如

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多