[英]Contact list not accessing all contacts phonegap
我在appery.io框架中的phonegap中创建了一个项目。 这不是基于cordova的项目,但我手动安装了cordova库。 我正在使用Jquery提取联系人列表,但它仅提取设备联系人列表而不是SIM联系人列表。 如果我想使用命令安装Cordova Contacts插件,则表明当前目录不是基于Cordova的项目。 如果有人可以帮助我,将不胜感激。
嗨,用它可以将所有联系人保存在sdcard中并显示。 (默认的Cordova联系人和文件插件)
document.addEventListener("deviceReady", deviceReady, false);
function deviceReady() {
navigator.contacts.find(["*"], function(contacts) {
//alert("contacts.length = " + contacts.length);
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fileSystem) {
fileSystem.root.getFile("contacts.json", {create: true, exclusive: false}, function(fileEntry) {
fileEntry.createWriter(function(writer) {
writer.onwriteend = function(){
// Success Contacts saved to sdcard as a contacts.json file
// Now get and read the json file
var path = fileSystem.root.getFile("contacts.json", {create:false},gotFileEntry, fail);
// jquery
$.getJSON(path, function (data) {
user = data;
$.each(user, function (index, user) {
var all_item = '<p id="'+user.id+'">'+user.displayName+'</p>';
$('#allcontacts').append(all_item);
});
});
};
writer.write(JSON.stringify(contacts));
}, onError);
}, onError);
}, onError);
}, onError,{"multiple": true});}
function onError(){
alert("Error");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.