Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Can't create a contact

Hello,

I try to create a contact on my iPhone app, like this:

    var contact = Titanium.Contacts.createPerson();
    contact.firstName = 'foo;
    contact.lastName = 'foo';
    contact.email = 'foo@foo.com';
    // contact.email.home = 'test@gmail.com'; //doesn't work too
    // contact.email = {"home": 'test@gmail.com'};//doesn't work too
    // contact.email = {home: 'test@gmail.com'};//doesn't work too
    // contact.email = {label: 'home', value: 'test@gmail.com'};//doesn't work too
    contact.organization = 'my organization';
    contact.jobTitle = '-';
    contact.phone = '321434343'; // crash the app, too

    Titanium.Contacts.save();

How create a contact with a firstname, lastname, email and address ?

Thanks!

— asked November 4th 2010 by Morgan Gan
  • 1.4.1
  • contact
  • iphone
  • mobile
0 Comments

2 Answers

  • Accepted Answer

    There was not a complete example in Kitchen Sink, but I figured it out

    contact.email = {"home": ["test@gmail.com"]};
    

    Here is a complete solution

    The trick is at the bottom of the [documentation for Contacts.Person2 regarding the structuring of the email and address objects.

    — answered November 7th 2010 by Aaron Saunders
    permalink
    0 Comments
  • Thank you very much !

    — answered November 7th 2010 by Morgan Gan
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.