I just noticed that my application is restarting every time when I go to device settings and there in Privacy -> Contacts allow/disallow it to use Contacts. This is strange behaviour for me but it is maybe default or something else is happening that I am not aware of? This is happening both on device and in simulator. Bellow is the mockup peace of code:
(function() { var self = Ti.UI.createWindow({ backgroundColor:'#fff' }); alert('Application started.'); var button = Ti.UI.createButton({ title : 'Save to Contacts', style : Ti.UI.iPhone.SystemButtonStyle.BORDERED }); self.add(button); //Add behavior for UI button.addEventListener('click', function(e) { Ti.Contacts.requestAuthorization(function(e) { if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED) { saveContact('Mladen', 'Mijatovic', '01010101', '02020202', 'dummy@something.com'); } else { addressBookDisallowed(); } }); }); self.open(); })(); function saveContact(firstName, lastName, mobilePhone, officePhone, email) { //query contacts to see if it is saved var person = Ti.Contacts.getPeopleWithName(firstName + ' ' + lastName); if (person.length > 0) { Ti.Contacts.removePerson(person[0]); Ti.Contacts.save(); } Ti.Contacts.createPerson({ firstName : firstName, lastName : lastName, phone : { mobile : [mobilePhone], work : [officePhone] }, email : { work : [email] } }); Ti.UI.createAlertDialog({ title : 'Success', message : 'Contact saved.' }).show(); } function addressBookDisallowed() { Ti.UI.createAlertDialog({ title : 'Error', message : 'No permission to write in Contacts.' }).show(); }My env is : Titanium SDK 3.2.2.GA, OS X Mavericks, iOS7, iOS simulator/iPad device