-
-
Save hansemannn/01f37c1fc6f31e818abd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win1 = Titanium.UI.createWindow({ | |
title: 'Tab 1', | |
backgroundColor: '#fff' | |
}); | |
Ti.Contacts.requestContactsPermissions(function(e) { | |
if (e.success == true) { | |
alert('permission success!'); | |
} else { | |
alert('permission failture!'); | |
} | |
}); | |
var createContact = Ti.UI.createButton({ | |
title: "Create New Contact", | |
}); | |
createContact.addEventListener('click', function(e) { | |
var pong = Ti.Contacts.createPerson({ | |
firstName: 'letter', | |
lastName: 'pong', | |
middleName: 'long', | |
nickname: 'fancyPants', | |
prefix: 'Mr', | |
suffix: 'Jr', | |
firstPhonetic: 'a', | |
middlePhonetic: 'b', | |
lastPhonetic: 'c', | |
organization: 'appcelerator', | |
department: 'SDK', | |
jobTitle: 'pingPongChampion', | |
note: 'when i was young, i ping pong to the top', | |
kind: Ti.Contacts.CONTACTS_KIND_PERSON, | |
address: { | |
work: [{ | |
CountryCode: 'gb', // determines how the address is displayed | |
Street: '200 Brook Drive\nGreen Park', | |
City: 'Reading', | |
Country: 'England', | |
PostalCode: 'RG2 6UB' | |
}, { | |
CountryCode: 'gb', // determines how the address is displayed | |
Street: '1 St Pauls Road\nClerkenwell', | |
City: 'City of London', | |
State: 'London', | |
Country: 'England', | |
PostalCode: 'EC1 1AA' | |
}], | |
home: [{ | |
CountryCode: 'gb', // determines how the address is displayed | |
Street: '2 Boleyn Court', | |
City: 'London', | |
State: 'Greenwich', | |
Country: 'England', | |
PostalCode: 'SE10' | |
}] | |
}, | |
email: { | |
home: [ | |
'myGmail', | |
'myHotmail' | |
], | |
work: [ | |
'myWorkemail' | |
] | |
}, | |
relatedNames: { | |
father: ['baba'], | |
mother: ['mama'], | |
child: ['gaga'] | |
}, | |
birthday: '2012-01-01T12:00:00.000+0000', | |
instantMessage: { | |
home: [{ | |
service: 'AIM', | |
username: 'leisureAIM' | |
}, { | |
service: 'MSN', | |
username: 'no_paul_here@msn.com' | |
}], | |
work: [{ | |
service: 'AIM', | |
username: 'seriousAIM' | |
}] | |
}, | |
organization: 'Appcelerator', | |
phone: { | |
main: ['07900 000001', '07900 000002'], | |
iPhone: ['+44 (0)118 925 6128', '+44 (0)118 000 0000'] | |
}, | |
alternateBirthday: { | |
calendarIdentifier: 'chinese', | |
day: 25, | |
era: 78, | |
isLeapMonth: false, | |
month: 11, | |
year: 16 | |
}, | |
socialProfile: { | |
home: [{ | |
service: 'facebook', | |
username: 'jdeep@facebook.com' | |
}, { | |
service: 'gamecenter', | |
username: 'jdeep@hotmail.com' | |
}], | |
work: [{ | |
service: 'linkedin', | |
username: 'jdeep@linkedin.com' | |
}] | |
}, | |
url: { | |
homepage: ['www.google.com'], | |
work: ['www.appcelerator.com', 'www.example.com'] | |
}, | |
date: { | |
anniversary: ['2006-06-25T12:00:00.000+0000', '2007-06-25T12:00:00.000+0000'], | |
other: ['2009-03-25T12:00:00.000+0000'] | |
} | |
}); | |
if (pong == null) { | |
alert("contact could not be created!"); | |
} else { | |
alert("contact successfully created!"); | |
} | |
}); | |
win1.add(createContact); | |
win1.open(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment