Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20010] iOS9: Remove Contacts causes app to crash

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-11-18T20:15:33.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sRelease 5.1.0
Componentsn/a
LabelsiOS9, qe-5.1.0
ReporterHarry Bryant
AssigneeChee Kiat Ng
Created2015-11-17T19:57:24.000+0000
Updated2015-11-20T18:25:27.000+0000

Description

Description:

This issue was located using KitchenSink, whilst testing Phone > Contacts > Remove Contact. Attempting to remove a contact using an app will cause it to crash, and after checking the native address book, the contact remains as existing. This problem affects iOS9 only, it does not occur when using the same code on an iOS8 device.

Steps to reproduce:

1.Import KitchenSink to iOS9 or Sim. 2. Navigate to Phone > Contacts > Remove Contact. 3. Select a contact to remove. 4. App will crash. 5. Navigate to native contacts book, and look for the entry selected in step 3. 6. the entry will still be present.

Result:

App will crash and fail to remove contact from address book.

Expected Result:

App should not crash, and should succeed in removing contact from address book.

Comments

  1. Hans Knöchel 2015-11-17

    PR (master): https://github.com/appcelerator/titanium_mobile/pull/7462 PR (5_1_X): https://github.com/appcelerator/titanium_mobile/pull/7463
  2. Chee Kiat Ng 2015-11-18

  3. Chee Kiat Ng 2015-11-18

    Master PR: https://github.com/appcelerator/titanium_mobile/pull/7464 5_1_X PR: https://github.com/appcelerator/titanium_mobile/pull/7465
  4. Chee Kiat Ng 2015-11-18

    Sample Code:
       var win = Ti.UI.createWindow({
       	backgroundColor: 'white'
       });
       
       var pong = null;
       var circleOfTrust = null;
       
       var btn = Ti.UI.createButton({
       	title: 'authorization status?',
       	top:'5%'
       });
       
       btn.addEventListener('click', function(e){
       	alert(Ti.Contacts.contactsAuthorization);
       });
       
       var btn2 = Ti.UI.createButton({
       	title: 'grant authorization',
       	top:'10%'
       });
       
       btn2.addEventListener('click', function(e){
       	Ti.Contacts.requestAuthorization(function(e) {
       		if (e.success == true) {
       			alert('success');
       		}
       		else {
       			alert('no');
       		}
       	});
       });
       
       var btn3 = Ti.UI.createButton({
       	title: 'show Contacts',
       	top:'15%'
       });
       
       btn3.addEventListener('click', function(e){
       	Ti.Contacts.showContacts({
       		cancel: function(e) {
       			alert('cancelled');
       		},
       //		selectedPerson: function(e) {
       //			var person = e.person;
       //			alert('person selected is ' + person.fullName + ' with identifier ' + person.identifier);
       //		},
       		selectedProperty: function(e) {
       			alert('property selected\n' + e.property +'\n' + e.label +'\n'+e.value);
       			Ti.API.info(e.value);
       //			Ti.API.info(e.person.fullName);
       //			Ti.API.info(e.property);
       //			Ti.API.info(e.value);
       //			Ti.API.info(e.label);
       		}
       	});
       });
       
       var btn4 = Ti.UI.createButton({
       	title: 'get All Contacts',
       	top:'20%'
       });
       
       btn4.addEventListener('click', function(e){
       	var people = Ti.Contacts.getAllPeople();
       	Ti.API.info(people);
       	for (var i = people.length - 1; i >= 0; i--) {
       		Ti.API.info(people[i].fullName);
       	};
       });
       
       var btn5 = Ti.UI.createButton({
       	title: 'get All Groups',
       	top:'25%'
       });
       
       btn5.addEventListener('click', function(e){
       	var groups = Ti.Contacts.getAllGroups();
       	Ti.API.info(groups);
       	for (var i = groups.length - 1; i >= 0; i--) {
       		Ti.API.info(groups[i].name);
       	};
       });
       
       var btn6 = Ti.UI.createButton({
       	title: 'get AppleSeed by identifier with image',
       	top:'30%'
       });
       
       btn6.addEventListener('click', function(e){
       	var people = Ti.Contacts.getAllPeople();
       	var person = Ti.Contacts.getPersonByIdentifier(people[0].identifier);
       	alert(person.fullName);
       	Ti.API.info(person.firstName);
       	Ti.API.info(person.birthday);
       	if (person.kind == Ti.Contacts.CONTACTS_KIND_PERSON) {
       		Ti.API.info('person is person');
       	} 
       	else if (person.kind == Ti.Contacts.CONTACTS_KIND_ORGANIZATION)	{
       		Ti.API.info('person is organization');
       	}
       	else {
       		Ti.API.info('unSupported kind??');
       	}
       	Ti.API.info(person.address);
       	Ti.API.info(person.instantMessage);
       	Ti.API.info(person.email);
       	Ti.API.info(person.socialProfile);
       	Ti.API.info(person.date);
       	Ti.API.info(person.phone);
       	Ti.API.info(person.relatedNames);	
       	Ti.API.info(person.url);
       	imgView.setImage(person.image);
       	imgView.show();
       });
       var btn7 = Ti.UI.createButton({
       	title: 'get first group by identifier',
       	top:'35%'
       });
       
       btn7.addEventListener('click', function(e){
       	var groups = Ti.Contacts.getAllGroups();
       	var group = Ti.Contacts.getGroupByIdentifier(groups[0].identifier);
       	alert(group.name);
       });
       var btn8 = Ti.UI.createButton({
       	title: 'get people with names John',
       	top:'40%'
       });
       
       btn8.addEventListener('click', function(e){
       	var people = Ti.Contacts.getPeopleWithName('john');
       	for (var i = people.length - 1; i >= 0; i--) {
       		Ti.API.info(people[i].fullName);
       //		Ti.API.info(people[i].lastName);
       	};
       	Ti.API.info(people[0].address);
       	Ti.API.info(people[0].birthday);
       //	Ti.API.info(people[1].instantMessage);
       //	Ti.API.info(people[0].email);
       //	Ti.API.info(people[0].socialProfile);
       //	Ti.API.info(people[0].alternateBirthday);
       //	Ti.API.info(people[0].date);
       	Ti.API.info(people[0].phone);
       //	Ti.API.info(people[1].relatedNames);	
       //	Ti.API.info(people[1].url);	
       
       });
       
       var btn9 = Ti.UI.createButton({
       	title: 'create new person pong',
       	top:'45%'
       });
       
       btn9.addEventListener('click', function(e){
       	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']
       	  }
       	});
       	alert('pong added. check in get all contacts');
       });
       
       
       
       var btn10 = Ti.UI.createButton({
       	title: 'create new group circleOfTrust',
       	top:'50%'
       });
       
       btn10.addEventListener('click', function(e){
       	circleOfTrust = Ti.Contacts.createGroup({
        		name: 'Circle Of Trust'
        	});
       	Ti.Contacts.save();
       	alert('circleOfTrust created. check in get All Groups');
       });
       
       var btn11 = Ti.UI.createButton({
       	title: 'add pong to circleOfTrust',
       	top:'55%'
       });
       
       btn11.addEventListener('click', function(e){
       	circleOfTrust.add(pong);
       	alert('pong added to group.');
       });
       
       var btn12 = Ti.UI.createButton({
       	title: 'Remove pong from circleOfTrust',
       	top:'60%'
       });
       
       btn12.addEventListener('click', function(e){
       	circleOfTrust.remove(pong);
       	Ti.Contacts.save();
       	alert('pong removed from group.');
       });
       
       var btn13 = Ti.UI.createButton({
       	title: 'Remove circleOfTrust',
       	top:'65%'
       });
       
       btn13.addEventListener('click', function(e){
       	Ti.Contacts.removeGroup(circleOfTrust);
       	Ti.Contacts.save();
       	alert('circleOfTrust removed. check in get All Groups');
       });
       
       var btn14 = Ti.UI.createButton({
       	title: 'Remove pong',
       	top:'70%'
       });
       
       btn14.addEventListener('click', function(e){
       	Ti.Contacts.removePerson(pong);
       	Ti.Contacts.save();
       	alert('pong removed. check in get all Contacts');
       });
       
       var btn15 = Ti.UI.createButton({
       	title: 'add 5 guys to circleOfTrust',
       	top:'75%'
       });
       btn15.addEventListener('click', function(e){
       	var all = Ti.Contacts.getAllPeople();
       	for (var i = 0; i < 5; i++) {
       		circleOfTrust.add(all[i]);
       	};	
       	alert('5 guys added');
       });
       
       var btn16 = Ti.UI.createButton({
       	title: 'see all members in circle of trust',
       	top:'80%'
       });
       
       btn16.addEventListener('click', function(e){
       	var members = circleOfTrust.members();
       	for (var i = 0; i < members.length; i++) {
       		Ti.API.info(members[i].fullName);
       	};
       });
       
       var btn17 = Ti.UI.createButton({
       	title: 'sorted firstName in circleoftrust',
       	top:'85%'
       });
       
       btn17.addEventListener('click', function(e){
       	var members = circleOfTrust.sortedMembers(Ti.Contacts.CONTACTS_SORT_FIRST_NAME);
       	Ti.API.info(members);
       	for (var i = 0; i < members.length; i++) {
       		Ti.API.info(members[i].fullName);
       	};
       });
       
       var btn18 = Ti.UI.createButton({
       	title: 'sorted lastName in circleoftrust',
       	top:'90%'
       });
       
       btn18.addEventListener('click', function(e){
       	var members = circleOfTrust.sortedMembers(Ti.Contacts.CONTACTS_SORT_LAST_NAME);
       	for (var i = 0; i < members.length; i++) {
       		Ti.API.info(members[i].fullName);
       	};
       });
       
       var imgView = Ti.UI.createImageView({
       	top:'95%',
       	height:'5%',
       	width: '5%'
       })
       
       Ti.Contacts.addEventListener('reload', function() {
       	Ti.API.info('contacts changed outside!');
       });
       win.add(btn);
       win.add(btn2);
       win.add(btn3);
       win.add(btn4);
       win.add(btn5);
       win.add(btn6);
       win.add(btn7);
       win.add(btn8);
       win.add(btn9);
       win.add(btn10);
       win.add(btn11);
       win.add(btn12);
       win.add(btn13);
       win.add(btn14);
       win.add(btn15);
       win.add(btn16);
       win.add(btn17);
       win.add(btn18);
       win.add(imgView);
       win.open();
       
  5. Chee Kiat Ng 2015-11-18

    Steps to test

    1. grant authorisation 2. create new person pong 3. create new group circleOfTrust 4. add pong to circleOfTrust 5. remove pong from circleOfTrust 6. remove circleOfTrust 7. remove pong
  6. Harry Bryant 2015-11-18

JSON Source