【问题标题】:How do I get Facebook and custom social addresses from iOS address book?如何从 iOS 通讯录中获取 Facebook 和自定义社交地址?
【发布时间】:2014-05-03 18:07:50
【问题描述】:

在我的 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+”是否有自定义社交条目(我的应用可以在其他地方创建这些条目),如果有,我也想导入该值。我该怎么做?

谢谢!

【问题讨论】:

    标签: ios import addressbook social abaddressbook


    【解决方案1】:

    叹息

    我想通了。这是我所做的:

        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);
    

    【讨论】:

    猜你喜欢
    • 2013-04-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多