有没有办法只显示有电话号码的联系人?
现在我正在获取所有联系人,然后遍历每个联系人并找出他们的电话号码,但我想知道是否有办法将参数传递给contactFindOptions
对象,以便它只获取具有电话号码的联系人?
这就是我的代码当前的样子:
var options = new ContactFindOptions();
options.filter=""; //Can i pass something here to pick only contacts with phone number
options.multiple=true;
var fields = ["displayName", "phoneNumbers"];
navigator.contacts.find(fields, onSuccess, onError, options);
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
console.log("Display Name = " + contacts[i].displayName);
if(null != contacts[i].phoneNumbers)
{
for(var j=0;j<contacts[i].phoneNumbers.length;j++)
{
console.log("Name = " + contacts[i].displayName);
console.log("Phone = " + contacts[i].phoneNumber[j].value);
}
}
}
}