【问题标题】:Contact list not accessing all contacts phonegap联系人列表未访问所有联系人 phonegap
【发布时间】:2015-10-29 04:25:36
【问题描述】:

我在 appery.io 框架的 phonegap 中创建了一个项目。它不是基于科尔多瓦的项目,但我手动安装了科尔多瓦库。我正在使用 Jquery 获取联系人列表,但它仅获取设备联系人列表而不是 sim 联系人列表。如果我想使用命令安装cordova 联系人插件,那么它显示当前目录不是基于cordova 的项目。如果有人可以帮助我,将不胜感激。

【问题讨论】:

  • 附带说明,如果您在 Appery.io 中创建了一个应用程序,它会与 Apache Cordova 捆绑在一起。

标签: ios cordova


【解决方案1】:

您好,使用它可以将所有联系人保存在 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"); 
             }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-08-16
    • 2011-05-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    相关资源
    最近更新 更多