I am using the following to code to retrieve the social profiles from Address Book in iOS 6:
// get the address book
ABAddressBookRef addressBook = ABAddressBookCreateWithOptions(options, error);
// get all people
CFArrayRef allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
// get the number of people
CFIndex noOfPeople = ABAddressBookGetPersonCount(addressBook);
// for all people
for (CFIndex personIndex = 0; personIndex<noOfPeople; personIndex++)
{
// get social profiles
NSMutableArray *socialProfilesArray = [[NSMutableArray alloc] init];
ABMultiValueRef socialProfiles = ABRecordCopyValue(person, kABPersonSocialProfileProperty);
for(CFIndex j = 0; j < ABMultiValueGetCount(socialProfiles); j++)
{
NSDictionary* socialProfile = (NSDictionary*)ABMultiValueCopyValueAtIndex(socialProfiles, j);
if ([socialProfile[@"service"] isEqualToString:(NSString*)kABPersonSocialProfileServiceFacebook])
{
NSString *strFacebook = (NSString*)socialProfile[@"username"];
}
else if ([socialProfile[@"service"] isEqualToString:( NSString*)kABPersonSocialProfileServiceTwitter])
{
NSString *twitterName = (NSString*)socialProfile[@"username"];
}
[socialProfilesArray addObject:socialProfile];
[socialProfile release];
}
CFRelease(socialProfiles);
}
It appears that while I successfully get a Twitter profile, no Facebook profile is returned. And that is despite that there is clearly a Facebook profile associated with one of my contacts, as indicated in the contacts application.
Any ideas why?