gpt4 book ai didi

iphone - 从 Facebook 同步获取电话号码/"Unified Info"地址簿联系人

转载 作者:可可西里 更新时间:2023-11-01 05:56:20 24 4
gpt4 key购买 nike

我需要能够从用户的地址簿中读取联系人的电话号码。问题是,如果用户选择通过 Facebook 同步这些联系人,则无法再通过以下代码访问它们(这对未同步的联系人有效):

ABMultiValueRef phones = ABRecordCopyValue(record, kABPersonPhoneProperty);
DLog(@"Found %ld phones", ABMultiValueGetCount(phones));
for(CFIndex j = 0; j < ABMultiValueGetCount(phones); j++)
{
CFStringRef phoneNumberRef = ABMultiValueCopyValueAtIndex(phones, j);
CFStringRef locLabel = ABMultiValueCopyLabelAtIndex(phones, j);
NSString *phoneLabel =(__bridge NSString*) ABAddressBookCopyLocalizedLabel(locLabel);
NSString *phoneNumber = (__bridge NSString *)phoneNumberRef;
CFRelease(phoneNumberRef);
CFRelease(locLabel);
DLog(@" - %@ (%@)", phoneNumber, phoneLabel);
[numbersArr addObject:phoneNumber];
}

日志结果是[Line 126] Found 0 phones

我尝试使用 CFArrayRef userNumbers = ABMultiValueCopyArrayOfAllValues(phoneNumbers);
,但这也没有返回任何内容:[Line 118] Got user numbers: (null)

所以我尝试深入了解社交资料,但也一无所获!

// Try to get phone numbers from social profile
ABMultiValueRef profiles = ABRecordCopyValue(record, kABPersonSocialProfileProperty);
CFIndex multiCount = ABMultiValueGetCount(profiles);
for (CFIndex i=0; i<multiCount; i++) {
NSDictionary* profile = (__bridge NSDictionary*)ABMultiValueCopyValueAtIndex(profiles, i);
NSLog(@"TESTING - Profile: %@", profile);

}
DLog(@"Got profiles: %@", profiles);
CFRelease(profiles);

但是日志条目是:[第 161 行] 获得配置文件:ABMultiValueRef 0x1ddbb5c0,具有 0 个值

如果以上结果都没有给我任何结果,我应该如何知道他们是 Facebook 用户并获取他们的电话信息?

最佳答案

来自 Apple 支持:

We do not have any APIs that will return a unified Address Book contact. However, you can retrieve phone numbers of contacts that appear as unified in Contacts on your device by first using ABPersonCopyArrayOfAllLinkedPeople to retrieve all linked contacts, then iterating through these contacts to fetch their respective phone numbers. Note that phone numbers that do not appear in the UI in Contacts will not be returned by Address Book APIs. See below for a snippet of code that will allow you to do so:

- (BOOL)peoplePickerNavigationController:(ABPeoplePickerNavigationController *)peoplePicker shouldContinueAfterSelectingPerson:(ABRecordRef)person

{

//Fetch all linked contacts

CFArrayRef linkedPerson = ABPersonCopyArrayOfAllLinkedPeople(person);

//Iterate through each linked contact to fetch the phone numbers

for (CFIndex i = 0; i < CFArrayGetCount(linkedPerson); i++)

{

ABRecordRef contact = CFArrayGetValueAtIndex(linkedPerson,i);

ABMutableMultiValueRef multi = ABRecordCopyValue(contact, kABPersonPhoneProperty);

for (CFIndex i = 0; i < ABMultiValueGetCount(multi); i++)

{

CFStringRef label = ABMultiValueCopyLabelAtIndex(multi, i);

CFStringRef number = ABMultiValueCopyValueAtIndex(multi, i);

CFRelease(label);

CFRelease(number);

}

CFRelease(multi);

}

CFRelease(linkedPerson);

return YES;

关于iphone - 从 Facebook 同步获取电话号码/"Unified Info"地址簿联系人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15214370/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com