Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19896

iOS: Ti.Contacts.getAllPeople() | Custom fields for phone, address and email returns undefined

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: Release 5.1.0
    • Fix Version/s: Release 5.1.0
    • Component/s: iOS
    • Environment:
    • Story Points:
      3
    • Sprint:
      2015 Sprint 23 SDK

      Description

      When trying to show information about contacts from the iOS Contacts app which have custom field names for phone numbers or emails or address, the Ti.Contacts.Person property 'email', 'phone' or 'adress' is undefined. Which means you can't retrieve any of the emails, phone numbers or addresses (with custom field names) associated with the contact.

      To replicate, start iOS (version 9.x) simulator. Add a new contact, add one email address with one of the default "labels" provided by iOS, run test code (see below), the email address is listed in the console (as expected), modify the newly added person and add another email address but define a custom label to this entry, run code, the "email" property will be undefined. This can also be reproduced for the "phone" and "address" properties.

      Tested with Ti SDK 5.0.2.GA

      Example

      var win = Ti.UI.createWindow({
      	backgroundColor: '#fff',
      });
       
      var performAddressBookFunction = function() {
      	var singleValue = ['firstName', 'lastName', 'fullName'];
      	var multiValue = ['email', 'address', 'phone'];
      	var people = Ti.Contacts.getAllPeople();
      	Ti.API.info('Total contacts: ' + people.length);
      	for (var i = 0,
      	    ilen = people.length; i < ilen; i ++) {
      		Ti.API.info('---------------------');
      		var person = people[i];
      		for (var j = 0, jlen = singleValue.length; j < jlen; j ++) {
      			Ti.API.info(singleValue[j] + ': ' + person[singleValue[j]]);
      		}
      		for (var j = 0, jlen = multiValue.length; j < jlen; j ++) {
      			Ti.API.info(multiValue[j] + ': ' + JSON.stringify(person[multiValue[j]]));
      		}
      	}
       
      };
       
      var addressBookDisallowed = function() {
      	alert('Hey! You disallowed this, why?');
      };
       
      var button = Ti.UI.createButton({
      	title: 'Output contacts to console',
      	height: 50
      });
      win.add(button);
       
      button.addEventListener('click', function() {
      	Ti.Contacts.requestAuthorization(function(e) {
      		if (e.success){
      			performAddressBookFunction();
      		} else {
      			addressBookDisallowed();
      		}
      	});
      });
       
      win.open();
      

        Attachments

          Activity

            People

            • Assignee:
              cng Chee Kiat Ng (Inactive)
              Reporter:
              woodoo Michael Woode
              Reviewer:
              Hans Knöchel
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-20622
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code