Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11174] iOS 6: Ti.Contacts-Module broken

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2012-10-06T02:46:21.000+0000
Affected Version/sn/a
Fix Version/sRelease 2.1.3, Release 3.0.0, Sprint 2012-20 API, 2012 Sprint 20
ComponentsiOS
Labelsapi, contacts, device, ios, ios6, iphone, qe-ios6, qe-port
ReporterHans Knöchel
AssigneeBlain Hamon
Created2012-09-25T16:34:44.000+0000
Updated2012-10-06T02:46:21.000+0000

Description

The method "getAllContacts()" of the Ti.Contacts is broken when installing the app on a device (tested with Ti-SDK 2.1.3 GM, iOS 6 and iPhone 5). It works great in the simulator but not on the given device. *Code-Example:*
var data = [];
 
var contacts = Titanium.Contacts.getAllPeople();
 
for (var i = 0; i < contacts.length; i++) {
    data.push({
        name : contacts[i].firstName,
        surname : contacts[i].lastName,
        phone : contacts[i].phone
    });
}

Ti.API.info("Collected Contacts: \n"+data);

Comments

  1. Ingo Muschenetz 2012-09-26

    What is the behavior you see on device? Is there just no data?
  2. Hans Knöchel 2012-09-26

    Yes, there is just returned an empty array (data). Note: After i used Ti.Contacts.showContacts(), granted the permission for the contacts and then tried it again, the data was given. So it's obviously a bug where we need to ask for permissions to access the contacts (like in the Geolocation-API).
  3. Lokesh Choudhary 2012-09-26

    Able to reproduce the issue on SDK : 2.1.3.v20120921190208 & Iphone 5- iOS6. It does not ask for any permissions to access contacts & we get a empty array. Also,building with iOS SDK 5.1 & titanium SDK 2.1.2 GA asks us for the permission to access the contacts. Running in simulator for iOS SDK 5.1 & titanium SDK 2.1.2 GA returns us "Collected Contacts : [objects,objects],...."
  4. Sabil Rahim 2012-09-28

    Expanded test case
        var win = Ti.UI.createWindow({backgroundColor:'gray'}); 
        var label = Ti.UI.createLabel({
        					text:'Check log for contacts details.',
        					width:Ti.UI.SIZE,
        					height:Ti.UI.SIZE,
        			});
       win.add(label);
       
        					
        var performAddressBookFunction = function(){
        		var data = [];
         
       		var contacts = Titanium.Contacts.getAllPeople();
       		Ti.API.info("Collected Contacts: data length : "+ data.length);  
       		for (var i = 0; i < contacts.length; i++) {
       		    data.push({
       		        name : contacts[i].firstName,
       		        surname : contacts[i].lastName,
       		        phone : contacts[i].phone
       		    });
       			Ti.API.info(" \n"+data[i].name + ' ' + data[i].surname);
       		}
       		 
       		
       };
       var addressBookDisallowed = function(){
        	Titanium.UI.createAlertDialog({
       		title:'CONTACTS ACCESS DENIED', 
       		message:'Your app does not have access to the Contacts database. Please check privacy settings.'
        	}).show();
        };
        if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
            performAddressBookFunction();
        }
        else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN){
            Ti.Contacts.requestAuthorization(function(e){
                if (e.success) {
                    performAddressBookFunction();
                } 
                else {
                	 label.text= 'contacts not available.';
                    addressBookDisallowed();
                }
            });
        } 
        else {
            addressBookDisallowed();
        }
       
       win.open();
       
  5. Sabil Rahim 2012-09-29

    Master PR https://github.com/appcelerator/titanium_mobile/pull/3078 2_1_X PR https://github.com/appcelerator/titanium_mobile/pull/3084
  6. Olga Romero 2012-10-01

    Verified fix with: Titanium Studio, build: 2.1.2.201208301612 Titanium SDK: 3.0.0.v20120929141713 Titanium SDK: 2.1.3.v20120928203111 Devices: iPhone4 ios5.1.1 iPhone5 ios 6.0 Closing the bug.
  7. Ingo Muschenetz 2012-10-06

    Reopened to adjust remaining estimate.

JSON Source