Titanium Community Questions & Answer Archive

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

Docs for Contacts API?

Hi!
I'm trying to use the Contacts API.
However, unfortunately, this is currently neither in the Docs or in the Kitchensink example.
The best docs I could find are at
https://appcelerator.lighthouseapp.com/projects/32238/tickets/176-api-contacts-dialog
While I get a contact picker working, with Titanium.Contacts.showContactPicker from the return info I can get the name, but not the Phonenumber:
Titanium.API.info('Phonenr:'+event.contact.phoneNumber);
doesn't work.
Anybody got an working example, or better docs?
Thanks!

— asked April 26th 2010 by Martijn Pannevis
  • android
  • api
  • contacts
  • docs
  • iphone
  • mobile
1 Comment
  • I need better support for the AB on both iPHONE and ANDROID… kind of urgent as I already committed to do a project using it. But I dont think the AB is ready… So I wanted to ask the Ti-iPHONE staff if this would be a sensible idea… I was thinking of doing an AB extension in xCODE… Am I biting off more than I can chew here? I do know ObjC, and the AB api, but if this issue is already resolved, but I just need to find the docs, I would prefer to not re-invent the wheel. can I get some more advice on what to do here?

    — commented July 10th 2010 by vincent youmans

8 Answers

  • You need to consider this Q&A entry when handling Android contacts: http://developer.appcelerator.com/question/126472/android-how-to-get-email-from-person-in-contacts

    You should also check the current Titanium.Contacts API docs as pretty much all properties of returned contacts are accounted for.

    Finally, Android cannot add/edit contacts via the core Titanium.Contacts API, but you can do it by using Android Intents. Check out the "Forging Titanium Episode 9: Android Intent Cookbook" screencast to see exactly how to do this.

    — answered October 5th 2011 by Tony Lukasavage
    permalink
    0 Comments
  • Martijn,

    Did you get this figured out? I'm trying to do something similar. I want to only pick a user with a phone number. If I set the details parameter to

        details:['firstName','lastName','phoneNumber']
    

    I get a contact record with first name, last name and nothing else.

    — answered May 17th 2010 by Curtis Olson
    permalink
    0 Comments
  • It took quite some figuring out, but I now use Titanium.API.info('Phonenr:'+event.contact.phone[0].value);
    for the phonenumber. That (mostly) works, altho not on all numbers.
    However, the iPhone also includes a picker that allows the user (in the modal) to not only select a person, but only a number. I really hope there is a way to call this from Titanium too, but I haven't figured it out yet…
    Let me know if you do!

    — answered May 17th 2010 by Martijn Pannevis
    permalink
    0 Comments
  • To make things clearer: The variable for phonenumber is phone. Not phonenumber.
    Thanks for the details example, helped me a lot!

    — answered May 17th 2010 by Martijn Pannevis
    permalink
    0 Comments
  • Hi there,

    contact.phone[0].value works for phone numbers on iPhone and simulator, but contact.email[0].value crashes my app on iPhone. It works as expected on simulator. Any tips?

    — answered May 21st 2010 by Hans Johansson
    permalink
    0 Comments
  • Nope, and I'm also having some issues with crashing:

    I have 2 issues. The main issue is that if a contact has multiple contacts, and I select the not-first phonenumber, the app crashes on reading the number. No error messages, it just crashes.
    The second is that it also crashes on reading the organisation.
    My (simplified) code:
    Titanium.Contacts.showContactPicker({
    success:function(event){
    var phonenr=event.contact.phone[0].value; //This crashes if I pick the not-first phone number for the contact.
    var org=event.contact.organization; //This always crashes
    },
    details:['firstName','lastName','phone','organization']
    });
    Any insight is welcome!

    — answered May 21st 2010 by Martijn Pannevis
    permalink
    0 Comments
  • I wanted to get a status on the issues above. I have a project where I need to get at the NATIVE Address book, and I would really like to hear some success stories as well as how you did it. perhaps some sample code. And some gotchas…

    — answered July 8th 2010 by vincent youmans
    permalink
    0 Comments
  • An update: I did use (and ship) a project (on iPhone) using Contacts. As the details were too buggy (crashed when a contact had more than 1 phonenumber) I implemented this myself.

    — answered July 8th 2010 by Martijn Pannevis
    permalink
    2 Comments
    • The contacts API has recently had a really decent overhall in Ti. Would be good to check it out again and see if the issues you were experiencing before are still around.

      — commented July 8th 2010 by David Ashwood
    • hey dave… I have been following the AB thing for a while, and all the docs I can find are:
      http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Contacts-module
      is there more docs than this? I get the sense that the AB is not at all ready for prime time, but its such a vital API.. are there no samples out there to check out?

      — commented July 10th 2010 by vincent youmans
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.