jeudi 3 juillet 2014

Why am I able to load Contacts from my Android phone with the Cordova Contact API but not on ios?


Vote count:

0




I'm building a cross platform phone app using dhtml and steroids.js which is built on top of Phonegap. I'm trying to use the Cordova Contact API to load Contacts from my phone into an ul element. Here is the code I have inside of my head tags. It works fine when I load my app on my Android device but not on an iphone4 or 5.



<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Cordova is ready
//
function onDeviceReady() {
// find all contacts
var options = new ContactFindOptions();
options.filter="";
options.multiple=true;
var filter = ["*"];
navigator.contacts.find(filter, onSuccess, onError, options);


}

// onSuccess: Get a snapshot of the current contacts
//
function onSuccess(contacts) {

for (var i=0; i<contacts.length; i++) {
//alert(contacts[i].displayName);


var mycontact = contacts[i].displayName;
alert(mycontact);

//Just making sure if a contact is null, it won't be appended to the ul.
if(mycontact == null){
}
else
{
// Using a little juqery to append to contacts to the ul
$("#contactlist").append('<li style="background-color:rgb (184,249,255);height:70px;overflow:hidden;border-top:solid 1px; border-bottom:solid 1px background-color:rgb(184,249,255);"><p style="font-family: Arial;font-size: 18px;top: 5px;position: relative;left: 10px;">' + mycontact + '</p></li>');
}


}


// ele.innerHTML = str;
}

// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}
</script>


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire