Skip to content

Instantly share code, notes, and snippets.

@billdawson
Created September 15, 2010 20:53
Show Gist options
  • Save billdawson/581465 to your computer and use it in GitHub Desktop.
Save billdawson/581465 to your computer and use it in GitHub Desktop.
Show data for all contacts (Titanium)
function dosubs(person, property, labels) {
if (!(person[property])) {
return;
}
var pset = person[property];
for (var i = 0; i < labels.length; i++) {
var label = labels[i];
if (!(pset[label])) {
continue;
}
var values = pset[label];
for (var j = 0; j < values.length; j++) {
var value = values[j];
if (typeof value === 'object' && "Street" in value) {
Ti.API.info(label + ' ' + property + ': ' + value.Street);
} else {
Ti.API.info(label + ' ' + property + ': ' + value);
}
}
}
}
function info(person) {
var fullName = person.fullName || "[no name]";
Ti.API.info("===================");
Ti.API.info("Name: " + fullName);
if (person.note && person.note.length > 0) {
Ti.API.info("Note: " + person.note);
}
dosubs(person, "email", ['home', 'work', 'other']);
dosubs(person, "address", ['home', 'work', 'other'], "");
dosubs(person, "phone", ['home', 'work', 'other', 'mobile', 'workFax', 'pager', 'homeFax', 'main']);
}
var people = Ti.Contacts.getAllPeople();
for (var i = 0; i < people.length; i++) {
var person = people[i];
info(person);
}
@MichaelStrong23
Copy link

You saved my day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment