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
While I get a contact picker working, with Titanium.Contacts.showContactPicker from the return info I can get the name, but not the Phonenumber:
Anybody got an working example, or better docs?
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.
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
I get a contact record with first name, last name and nothing else.
It took quite some figuring out, but I now use Titanium.API.info('Phonenr:'+event.contact.phone.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!
To make things clearer: The variable for phonenumber is phone. Not phonenumber.
Thanks for the details example, helped me a lot!
contact.phone.value works for phone numbers on iPhone and simulator, but contact.email.value crashes my app on iPhone. It works as expected on simulator. Any tips?
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:
var phonenr=event.contact.phone.value; //This crashes if I pick the not-first phone number for the contact.
var org=event.contact.organization; //This always crashes
Any insight is welcome!
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…
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.