Project: titanium
Issue TIMOB-19473: iOS9: Ti Contact might lead to a app crash
h6.Reproduce 1.Simply run the following code. {code} Titanium.UI.setBackgroundColor('#000'); var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor:'#fff' }); var addButton = Ti.UI.createButton({	title: "Add Contact",	top: "100",	left: "100" }); addButton.addEventListener('click', function() {	addToDeviceContacts('Lorem', 'Ipsum'); }); win1.add(addButton); var searchButton = Ti.UI.createButton({	title: "Search Contact",	top: "300",	left: "100" }); searchButton.addEventListener('click', function() {	var flag = searchPhoneBookContact('Lorem', 'Ipsum');	if (flag == true) {	alert("Contact Available");	} else if (flag == false) {	alert(" Contact Not Available");	} }); win1.add(searchButton); win1.open(); function addToDeviceContacts(firstname, lastname) {	if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED) {	addContact(firstname, lastname);	} else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN) {	Ti.Contacts.requestAuthorization(function(e) {	if (e.success) {	addContact(firstname, lastname);	} else {	addressBookDisallowed();	}	});	} else {	addressBookDisallowed();	} }; function addContact(firstname, lastname) {	var work_address = {	};	work_address.Street = 'street';	work_address.City = 'workAddress';	work_address.Country = 'country';	var tempMobile = '9999988888';	var tempPhone = '000000000';	var tempEmail = 'test@gmail.com';	var contact = Titanium.Contacts.createPerson({	firstName : (firstname != undefined) ? (firstname) : 'FirstName',	lastName : (lastname != undefined) ? (lastname) : 'LastName',	email : {	work : [tempEmail]	},	address : {	work : [work_address]	},	phone : {	mobile : [tempMobile],	"main" : [tempPhone]	},	note : 'Saved from app'	});	alert('Contact saved'); } function searchPhoneBookContact(firstname, lastname) {	if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED) {	var flag = performSearchFunction(firstname, lastname);	return flag;	} else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN) {	Ti.Contacts.requestAuthorization(function(e) {	if (e.success) {	var flag = performSearchFunction(firstname, lastname);	return flag;	} else {	Ti.API.info("address book disallowed");	}	});	} else {	Ti.API.info("address book disallowed");	} } function performSearchFunction(firstname, lastname) {	Ti.API.info("Address book Allowed");	if (Ti.Contacts.getPeopleWithName(firstname + ' ' + lastname).length > 0) {	return true;	} else {	return false;	} }; function addressBookDisallowed() {	alert('Phone book can not be accessed from this app!! Access denied'); } {code} 2.Click the add button to add a new contact 3.Click the search button. h6.Result: App will crash.
Story points: 5