シミュレーター/iPhone 5 では、Facebook からインポートされた連絡先がいくつかあります。現在、iPhone アドレス帳フレームワークを使用してこれらのプロファイルを読み取ろうとしています。残念ながら、何も返されません。以下は、私が現在使用しているコードスニペットです。
ABRecordRef person = ABAddressBookGetPersonWithRecordID(ABAddressBookCreate(), (ABRecordID)recordId)
ABMultiValueRef social = ABRecordCopyValue((__bridge ABRecordRef)person, kABPersonSocialProfileProperty);
//the count of 'social' is empty event there is a Facebook profile is attached to the contact.
if (social) {
for (int i = 0 ; i < ABMultiValueGetCount(social); i++) {
NSDictionary *socialDict = (NSDictionary *)ABMultiValueCopyValueAtIndex(social, i);
NSString* service = [socialDict valueForKey:(NSString *)kABPersonSocialProfileServiceKey];
NSString* username = [socialDict valueForKey:(NSString *)kABPersonSocialProfileUsernameKey];
NSLog(@"service... %@, username... %@", service, username);
}
}
CFRelease(social);
どんな助けでも感謝します。