ABMultiValueGetCount – kABPersonSocialProfileProperty总是返回0? 我怎样才能从地址簿获得Facebook的细节?

嗨,谁能告诉我为什么ABMultiValueGetCount(社会)总是返回0计数? 所有其他字段完美地从地址簿返回。

我正在尝试查看联系人是否有Twitter或Facebook活动? 我的用户在AB中定义了Twitter和Facebook。 我可以在那里看到他们!

/* The table view controller ViewDidLoad opened the AddressBook and copied these details into addressBookArray then I closed the reference to the AddressBook */ ABRecordRef person = (__bridge ABRecordRef)[addressBookArray objectAtIndex:indexPath.section]; /* Make sure AddressBook is currently open so we can look at things */ ABAddressBookRef addressBook; addressBook = ABAddressBookCreateWithOptions(NULL, NULL); if (addressBook != NULL) { NSString *firstName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSString *lastName = (__bridge_transfer NSString *)ABRecordCopyValue(person, kABPersonLastNameProperty); /* If I don't do this person always returns NULL for social */ ABRecordRef who = ABRecordCopyValue(ABAddressBookGetPersonWithRecordID (addressBook, ABRecordGetRecordID(person)); /* ABMultiValueRef social = ABRecordCopyValue(person, kABPersonSocialProfileProperty); - always returns NULL */ ABMultiValueRef social = ABRecordCopyValue(who, kABPersonSocialProfileProperty); // always returns a value /* C is always 0 even if user has FB/Twitter etc why ? */ CFIndex c = ABMultiValueGetCount(social); CFRelease (addressBook); } 

我读过这个问题:

ABRecordCopyValue返回0?

但是,如果我编辑一个AB联系人,并实际添加Twitter我还是没有得到一个结果。 还有另外一种解决这个问题的方法吗? 很明显,苹果公司就是这么做的,因为联系人应用程序告诉你这个事情。

好吧,取得了一些进展….

似乎这个属性确实工作kABPersonInstantMessageProperty。

分享我迄今为止所做的,因为这似乎阻碍了这么多的用户。 至less这个代码可以用来作为一个基础,看看你有Skype,雅虎,脸书等…..但我想要的FBID,并在kABPersonSocialProfileProperty下举行。 为什么不kABPersonSocialProfileProperty以及kABPersonInstantMessageProperty? 这是一个iOS 6的问题….

* 不,看起来,除非你手动去你的iOS设备上的设置 – Facebook – 更新所有联系人,地址簿不知道kABPersonSocialProfileProperty。 为什么苹果与这两个属性不一致? 此外,您必须select作为主要联系人创build的链接联系人也不具备这些细节! *

另外,为什么我必须分配“谁”而不能原生使用“人”呢?

任何人都有更多的想法?

 /* person is of type ABRecordRef loaded from an array thus: addressBookArray = (__bridge_transfer NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); ..... person = (__bridge ABRecordRef)[addressBookArray objectAtIndex:indexPath.section]; */ ABAddressBookRef addressBook; addressBook = ABAddressBookCreateWithOptions(NULL, NULL); if (addressBook != Nil) { int howManySocialApps; ABRecordRef who = ABAddressBookGetPersonWithRecordID (addressBook, ABRecordGetRecordID(person)); NSArray *linkedPeople = (__bridge_transfer NSArray *)ABPersonCopyArrayOfAllLinkedPeople (who); for (int x = 0; x < [linkedPeople count]; x++) { ABMultiValueRef socialApps = ABRecordCopyValue((__bridge ABRecordRef)[linkedPeople objectAtIndex:x], kABPersonSocialProfileProperty); CFIndex thisSocialAppCount = ABMultiValueGetCount(socialApps); for (int i = 0; i < thisSocialAppCount; i++) { NSDictionary *socialItem = (__bridge_transfer NSDictionary*)ABMultiValueCopyValueAtIndex(socialApps, i); NSLog(@"Social Item of type %@", [socialItem objectForKey:(NSString *)kABPersonSocialProfileServiceKey]); } if (socialApps != Nil) CFRelease(socialApps); howManySocialApps += thisSocialAppCount; } NSLog (@"Number of SocialApps Found is %i", howManySocialApps); CFRelease(addressBook); }