联系人列表无法访问所有联系人的电话间隙 [英] Contact list not accessing all contacts phonegap

查看:55
本文介绍了联系人列表无法访问所有联系人的电话间隙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I created a project in phonegap in appery.io framework. It is not cordova based project but I installed cordova library manually. I am fetching contacts list using Jquery but it is fetching only device contacts list not the sim contacts list. If i want to install cordova contacts plugin using commands then it is showing current directory is not a cordova based project. if anyone could help me out it would be much appreciated.

推荐答案

您好,可以使用此选项将所有联系人保存在sdcard中并显示. (默认的Cordova联系人和文件插件)

Hi use this to save all contacts in sdcard and display. (default Cordova contacts and file plugin)

 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"); 
             }

这篇关于联系人列表无法访问所有联系人的电话间隙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆