在Android上,联系插件对我不起作用 . 我正在使用phonegap构建我在config.xml中添加了这个
<gap:plugin name="org.apache.cordova.contacts" />
这是我的代码:
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
// specify contact search criteria
var options = new ContactFindOptions();
options.filter=""; // empty search string returns all contacts
options.multiple=true; // return multiple results
filter = ["displayName"]; // return contact.displayName field
navigator.contacts.find(filter, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
alert(contacts[i].displayName);
}
};
// onError: Failed to get the contacts
function onError(contactError) {
alert('onError!');
}
任何人都可以帮助我,原因可能是什么?
我还需要获取特定组的联系人 . 我无法在文档中的任何地方 . 是否支持任何可用的联系人插件?
1 回答
尝试在回调函数中添加范围:
onSuccess
和onError
在您的联系人函数调用中 . 使用您应用的主要范围app
或您设置的任何内容 .