phonegap

 

iPhone: Add a contact

Page history last edited by Steve Swinsburg 5 mos ago
##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.ContactManager.newContact(sample_contact, addContact_Return);
                        }
                }
        }
}


function addContact_Return(contact)
{
        if (contact) {
                navigator.notification.alert(contact.firstName + " " + contact.lastName, "Contact Returned", "Dismiss");
        }
}

Comments (0)

You don't have permission to comment on this page.