简体   繁体   中英

send sms in phonegap app

I have been trying to get contact list and send sms to a contact in phonegap app. 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. Code does not execute after navigator.contacts.find method. Can anyone please help me to resolve this problem.

JS Code

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

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

tried for android as well

<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. Please suggest Thanks

Earlier I was using phonegap build and it was the reason that contact was not retrieved. Now I used command line build and all contacts are fetched and sms plugin is also working fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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