简体   繁体   English

在phonegap应用中发送短信

[英]send sms in phonegap app

I have been trying to get contact list and send sms to a contact in phonegap app. 我一直在尝试获取联系人列表,并将短信发送到phonegap应用程序中的联系人。 I have tried with http://docs.phonegap.com/en/3.3.0/cordova_contacts_contacts.md.html#Contacts and https://github.com/aharris88/phonegap-sms-plugin but these are not working. 我已经尝试使用http://docs.phonegap.com/zh-CN/3.3.0/cordova_contacts_contacts.md.html#Contactshttps://github.com/aharris88/phonegap-sms-plugin,但它们无法正常工作。 Code does not execute after navigator.contacts.find method. 在navigator.contacts.find方法之后,代码不会执行。 Can anyone please help me to resolve this problem. 谁能帮我解决这个问题。

JS Code JS代码

var contactFxn = {
getContact : function(){
var options = new ContactFindOptions();
var filter = ["displayName", "name"];
options.filter= "";
options.multiple=true;
navigator.contacts.find(filter, this.onSuccess, this.onError, options);
//console.log(options);
},
onSuccess : function(contacts){
    for(var i = 0; i < contacts.length; i++){
        console.log(i);
    }  
},
onError : function(e){
    console.log(e);
}

};

function getContactTest() {
    contactFxn.getContact();
}

added plugin in config.xml as 在config.xml中添加插件为

<feature name="Contacts">
    <param name="ios-package" value="CDVContacts" />
</feature>

tried for android as well 也尝试过android

<feature name="Contacts">
    <param name="android-package" value="org.apache.cordova.contacts.ContactManager" />
</feature>

I am calling getContactTest() on a button click in html.I have checked it by putting alert in code, alert prints just before navigator.contacts.find and after that nothing happens. 我在html中单击按钮时调用了getContactTest()。我已经通过在代码中添加警报,在navigator.contacts.find之前以及之后什么都没有发生的情况下打印警报进行了检查。 Please suggest Thanks 请建议谢谢

Earlier I was using phonegap build and it was the reason that contact was not retrieved. 之前我使用phonegap构建,这是未检索到联系人的原因。 Now I used command line build and all contacts are fetched and sms plugin is also working fine. 现在,我使用命令行构建,并且提取了所有联系人,并且sms插件也可以正常工作。

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

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