简体   繁体   English

使用cordova将联系人保存到android应用程序

[英]save contact to android application using cordova

I have this code: 我有以下代码:

<!DOCTYPE html>
<html>
    <head>
        <script src="js/jquery.min.js"></script>
<script type="text/javascript">
function saveContact(wtspNum) {
var myContact = navigator.contacts.create({"displayName": "AnyScan"});

    var name = new ContactName();
    name.givenName = "example";
    name.familyName = " ";
    contact.name = name;

    var phoneNumbers = [];
    phoneNumbers[0] = new ContactField('mobile', wtspNum);
    contact.phoneNumbers = phoneNumbers;

    contact.save();
    };

</script>

    </head>

    <body>
    </script>
    <script type="text/javascript">
    $(document).ready(function() {
    $.getJSON("/app/conInfo.php",function(result){
    $.each(result, function(i, field){
    $("#contact").append("<a href='javascript:saveContact("+field.wtspNum+");'><img src='/im/wtsp.jpg'></a>");
    });
    });
    });
    </script>

    <div id="contactInfo" >
        <div id="contact"  ></div>
    </div>

    </body>
</html>

I want that when someone press the picture, it will call the saveContact function and save a number to the contact list of an android phone. 我希望有人按下图片时,它将调用saveContact函数并将一个号码保存到Android手机的联系人列表中。 Any help please.. 任何帮助请..

我已经在服务器端制作了一个php文件,该文件创建了一个vcf卡文件,然后将其下载到手机中。.我还没有找到另一种方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM