Phonegap Contacts API为除id和rowid之外的所有值返回null

时间:2017-03-13 20:42:33

标签: android cordova phonegap-plugins

我尝试了手机联系人api navigator.contacts.find()

联系人。 length显示为100+,但是当除了id和rowid

之外的所有对象值都为null
  {
        "id": "1654",
        "rawId": "1652",
        "displayName": null,
        "name": null,
        "nickname": null,
        "phoneNumbers": null,
        "emails": null,
        "addresses": null,
        "ims": null,
        "organizations": null,
        "birthday": null,
        "note": null,
        "photos": null,
        "categories": null,
        "urls": null
    },
    {
        "id": "1656",
        "rawId": "1653",
        "displayName": null,
        "name": null,
        "nickname": null,
        "phoneNumbers": null,
        "emails": null,
        "addresses": null,
        "ims": null,
        "organizations": null,
        "birthday": null,
        "note": null,
        "photos": null,
        "categories": null,
        "urls": null
    },
...

我的代码是

var options      = new ContactFindOptions();
    options.filter   = "";
    options.multiple = true;
    options.desiredFields = [navigator.contacts.fieldType.id];
    options.hasPhoneNumber = true;
    //var fields       = [navigator.contacts.fieldType.displayName,      
    navigator.contacts.fieldType.name];
    var fields       = ["*"];       
    navigator.contacts.find(fields, onSuccess, onError, options);

我是电话界的新手,有人帮忙吗?

2 个答案:

答案 0 :(得分:2)

请注释掉这一行:

//options.desiredFields = [navigator.contacts.fieldType.id];

这里指定结果应该只包含ids / rawIds

答案 1 :(得分:0)

设置: options.hasPhoneNumber = true;

那不应该是任何问题。