1

I am developing an iPhone app that opens the user's address book, it fetches the phone number of a person that user has selected from phone book. In case if the Address Book has a person having 2 or more phone numbers and user deletes one of the contacts,and after that user selects the contact from that person ,then the "ABPeoplePickerNavigationControllerDelegate" method -

(void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier NS_AVAILABLE_IOS(8_0);

gives wrong identifier.Else it is working fine.

Here is the code,that i am using to fetch the selected phone number from the address book.Does anyone have any idea why the delegate method isn't giving the correct identifier?

- (void)peoplePickerNavigationController:(ABPeoplePickerNavigationController*)peoplePicker didSelectPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier
{

if (property == kABPersonPhoneProperty)
{
    NSString* phoneNumber = nil;

    ABMultiValueRef phoneNumbers = ABRecordCopyValue(person,
                                                     property);

    if (ABMultiValueGetCount(phoneNumbers) > 0)
    {
        CFIndex index = ABMultiValueGetIndexForIdentifier(phoneNumbers, identifier);

 *//****  since identifier is wrong it returns index as -1 and app crashes in the below line *****
        phoneNumber = (__bridge_transfer NSString*) ABMultiValueCopyValueAtIndex(phoneNumbers, index);
    }

}

Shyam
  • 417
  • 4
  • 16
  • I am also having this problem. Did you find any solution / workaround? – barisdad Jun 28 '15 at 19:27
  • It's a bug in ABPeoplePickerNavigationController itsmz. Just a workaround is get all the values for the required property (in my case its the phone numbers) for the selected person, show it in your own table view and allow the user to select from there. – Shyam Jul 08 '15 at 13:34
  • please check my answer here : http://stackoverflow.com/a/31398923/1572408 – Rudi Jul 15 '15 at 07:00
  • @Rudi My question is not about getting person's info from address book.Please check above. The question is about getting correct identifier,since the above delegate returns wrong identifier,incase user deletes a number from his address book. – Shyam Jul 16 '15 at 05:01

0 Answers0