I want to get the phone number for a selected contact from the address book and then call that number, yet for some contacts this is achieved, while for others the returned phone number is NULL! I checked in my phone to see differences between 2 contacts (for one of them, the code returns the correct number, and for the other, it returns NULL) and I can see absolutely no difference (both contacts have first name, last name, and mobile phone number). I'm interested in the reason why this is happening and also for a solution to get the phone no. of a contact when it's available. Thanks in advance!
- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person {
ABMultiValueRef phoneNumberProperty = ABRecordCopyValue(person, kABPersonPhoneProperty);
NSArray* phoneNumbers = (__bridge NSArray*)ABMultiValueCopyArrayOfAllValues(phoneNumberProperty);
CFRelease(phoneNumberProperty);
if (phoneNumbers[0] != NULL) {;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"telprompt:%@", phoneNumbers[0]]]];
}
[self dismissViewControllerAnimated:YES completion:nil];
return NO;
}