Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19739] iOS: Ti.Contacts custom phone label in phones become undefined

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2015-10-21T17:38:57.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.1.0, Release 5.2.0
ComponentsiOS
Labelscontacts, ios, iphone
Reporterjack sparrow
AssigneeChee Kiat Ng
Created2015-10-16T06:51:02.000+0000
Updated2015-11-09T12:20:30.000+0000

Description

i need urgent solution for this bug in Contacts list phone numbers , IOS if i have contact he's phone number saved in custom label the phone numbers of this contact object return "undefined"
 var people          = Ti.Contacts.getAllPeople(); 

     for ( var i = 0 ; i < people.length; i++)
     {
     	var person  = people[i];
     	var contactPhones = person['phone'] ;//should be array 
     	//if contact has phone number saved as custom label return undefined;
     	Ti.API.info(i+' - Contact Phones '+contactPhones);
     }

Comments

  1. jack sparrow 2015-10-19

    anyone ?
  2. Fokke Zandbergen 2015-10-19

    [~jackSparrow] we have been able to reproduce the issue and will schedule it asap.
  3. Chee Kiat Ng 2015-10-20

    PR here : https://github.com/appcelerator/titanium_mobile/pull/7322
  4. Hans Knöchel 2015-10-20

    Tested the above demo code using the PR of [~cng]. Works fine, FT approved, PR merged, ticket resolved. Thank you!
  5. jack sparrow 2015-10-21

    yes the above demo by Chee is working fine on custom labels , but it cost another issue , when add new contact has default label it gives Error exception , for example add new contact but don't change the label keep it "phone" :
       if (key == nil )
               {
                   
                   @try {
                       key = [NSString stringWithString:genericProperty.label];
                   }
                   @catch (NSException *exception) {
                       
                       key = nil;
                       DebugLog(@"%@", exception.reason);
                       }
       	}
       
             //with or without key == nil , cost new contact issue 
               if (key == nil) {
                		DebugLog(@"Unable to find key for property");
                		return nil;
               }
       
    Console print out exception Error for new contact :
       *** -[NSPlaceholderString initWithString:]: nil argument
       
  6. Chee Kiat Ng 2015-10-21

    [~jackSparrow], sorry, I might be missing something here, i had no problem adding a new contact with default settings. can you write an example code (in JS) that explains the new problem?
  7. jack sparrow 2015-10-21

    Sorry my bad in explain , here what i did : 1- open phone dialog , write any phone number . 2- click on + icon to create new contact ( the number your wrote in dialog ) . 3- by default the label will be "phone" keep it and click save . now get contacts list using above code with bug fix , you will get Error exception :
       *** -[NSPlaceholderString initWithString:]: nil argument
       
    i did not tested it on simulator , tested on my iPhone.
  8. Chee Kiat Ng 2015-10-21

    good catch [~jackSparrow], this should be an apple bug since it's that value should be nonnull as according to the docs here: https://developer.apple.com/library/ios/documentation/Contacts/Reference/CNLabeledValue_Class/#//apple_ref/occ/instp/CNLabeledValue/label But PR here anyway, until Apple fixes it. https://github.com/appcelerator/titanium_mobile/pull/7325
  9. jack sparrow 2015-10-21

    @Chee Kiat Ng , you are the man (y)
  10. Hans Knöchel 2015-10-21

    PR tested and approved. [~jackSparrow], we will also supply this fix in the upcoming 5.1.0 version instead of 5.2.0. Thank you!
  11. Harry Bryant 2015-10-22

    Verified as fixed, tested on 9.1 iPhone 6S Plus device, using 5.0.2.GA release, I am able to reproduce the error. Creating a contact with custom label "phone" and running the app will log the contact as "undefined". rebuilding app with release 5.1.0.v20151021165224, the error is no longer reproducible. Mac OSX El Capitan 10.11 (15A284) Studio: 4.3.3.201510201834 Ti SDK: 5.1.0.v20151021165224 Appc NPM: 4.2.1-6 Appc CLI: 5.2.0-24 Ti CLI: 5.0.4 Xcode 7.1(7B91b) Node v0.12.7 production *Closing ticket.*
  12. Michael Woode 2015-11-09

JSON Source