在我的 peoplePickerNavigationController:shouldContinueAfterSelectingPerson 中,我能够从所选联系人中读取一堆 iOS 联系人信息到我的应用中。
我不知道如何阅读的一项是 Facebook(和其他社交)地址信息。这就是我所拥有的,我知道这不太正确。我认为问题与标签有关:
ABMultiValueRef socialRef = ABRecordCopyValue(person, kABPersonSocialProfileProperty);
for (int i = 0; i < ABMultiValueGetCount(socialRef); i++) {
CFStringRef currentSocialLabel = ABMultiValueCopyLabelAtIndex(socialRef, i);
CFStringRef currentSocialValue = ABMultiValueCopyValueAtIndex(socialRef, i);
if (CFStringCompare(currentSocialLabel, kABPersonSocialProfileServiceFacebook, 0) == kCFCompareEqualTo) {
[theContactInfoDictionary setObject:(__bridge NSString *)currentSocialValue forKey:@"theFacebook"];
}
CFRelease(currentSocialLabel);
CFRelease(currentSocialValue);
}
CFRelease(socialRef);
请指出正确的方向。
此外,我还需要检查是否有“Google+”的自定义社交条目(我的应用程序可以在其他地方创建这些条目),如果有,我也想导入该值。我该怎么做?
谢谢!
最佳答案
叹息
我想通了。这是我所做的:
ABMultiValueRef socialRef = ABRecordCopyValue(person, kABPersonSocialProfileProperty);
for (int i = 0; i < ABMultiValueGetCount(socialRef); i++) {
NSDictionary *socialDictionary = (__bridge NSDictionary *)ABMultiValueCopyValueAtIndex(socialRef, i);
if ([socialDictionary[@"service"] isEqualToString:(__bridge NSString *)kABPersonSocialProfileServiceFacebook]) {
[theContactInfoDictionary setObject:(NSString *)socialDictionary[@"username"] forKey:@"theFacebook"];
} else if ([socialDictionary[@"service"] isEqualToString:(__bridge NSString *)kABPersonSocialProfileServiceTwitter]) {
[theContactInfoDictionary setObject:(NSString *)socialDictionary[@"username"] forKey:@"theTwitter"];
} else if ([socialDictionary[@"service"] isEqualToString:@"Google+"]) {
[theContactInfoDictionary setObject:(NSString *)socialDictionary[@"username"] forKey:@"theGoogle"];
}
}
CFRelease(socialRef);
关于ios - 如何从 iOS 通讯录中获取 Facebook 和自定义社交地址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23448101/