ios - 如何从 iOS 通讯录中获取 Facebook 和自定义社交地址?

标签 ios abaddressbook

在我的 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/

相关文章:

ios - 隐藏在滚动/滑动后,UINavigationBar 不会再次显示

Android 获取所有联系人列表(姓名、电子邮件、电话)需要超过一分钟的时间来获取大约 700 个联系人

ios - 要求用户访问他们在地址簿中的联系人

ios - TabBarController 中的 PersonViewController

ios - 应用程序在 iPhone 中的 dispatch_queue 内崩溃

iphone - iPhone-通讯录搜索崩溃

ios - 使用 Twilio 我想使用 iOS 设备将第三方添加到通话中

ios - 混合 xib 的 UITableViewCell 和以编程方式生成的 UITableViewCells

ios - 从父类(super class)访问子类属性

iphone - FBFriendPickerViewController - 初始化之前选中的 friend