I am trying to get selected mobile phone number with
ABMultiValueRef phones = ABRecordCopyValue(person, property);
CFStringRef phoneNumber = ABMultiValueCopyValueAtIndex(phones, identifier);
I have a contact with several mobile phones (all labeled 'mobile'). When I select the first one, phoneNumber gives me the first one, but if I select any consecutive one, phoneNumber gives me the previous number:
Contact: Jay Jaymes mobile +1111111111 mobile +2222222222 mobile +3333333333
Tap first one, phoneNumber
= +1111111111
Tap second one, phoneNumber
= +1111111111
Tap third one, phoneNumber
= +2222222222
This is code I use. And It will give correct phone number only
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person property:(ABPropertyID)property identifier:(ABMultiValueIdentifier)identifier {
if (property == kABPersonPhoneProperty) {
ABMultiValueRef phoneProperty = ABRecordCopyValue(person,property);
CFIndex peopleIndex = ABMultiValueGetIndexForIdentifier(property, identifier);
NSString *phone = (__bridge_transfer NSString*)ABMultiValueCopyValueAtIndex(phoneProperty, peopleIndex);
[self dismissModalViewControllerAnimated:YES];
}
return NO;
}