FYI - these Contact examples are for 0.9.3 and before. Please see http://docs.phonegap.com/phonegap_contacts_contacts.md.html for 0.9.4 and beyond.
##PhoneGap addContact
function addContact(){
var sample_contact = { 'firstName': 'John', 'lastName' : 'Smith', 'phoneNumber': '555-5555' };
var firstName = prompt("Enter a first name", sample_contact.firstName);
if (firstName) {
var lastName = prompt("Enter a last name", sample_contact.lastName);
if (lastName) {
var phoneNumber = prompt("Enter a phone number", sample_contact.phoneNumber);
if (phoneNumber) {
sample_contact = { 'firstName': firstName, 'lastName' : lastName, 'phoneNumber' : phoneNumber };
navigator.contacts.newContact(sample_contact, addContact_Return);
}
}
}
}
function addContact_Return(contact)
{
if (contact) {
navigator.notification.alert(contact.firstName + " " + contact.lastName, "Contact Returned", "Dismiss");
}
}
Works great, can someone update it with the ability for EMail, Company Name and Address, or point us in the direction of where to find these variable names?
This doesn't seem to work on phonegap-iphone 0.9.3 unless you omit the callback function.