iphone – 从Facebook同步“统一信息”地址簿联系人获取电话号码

iphone – 从Facebook同步“统一信息”地址簿联系人获取电话号码,第1张

概述我需要能够从用户的地址簿中读取联系人电话号码.问题是,如果用户选择通过Facebook同步这些联系人,则无法再通过以下代码访问这些联系人(这对于未同步的联系人有效): ABMultiValueRef phones = ABRecordCopyValue(record, kABPersonPhoneProperty);DLog(@"Found %ld phones", ABMultiValueG 我需要能够从用户的地址簿中读取联系人的电话号码.问题是,如果用户选择通过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]找到0个电话号码

我曾尝试使用CFArrayRef userNumbers = ABMultiValuecopyArrayOfAllValues(phoneNumbers);
,但这也没有返回任何内容:[第118行]获得用户数:(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 contactsCFArrayRef linkedPerson = ABPersoncopyArrayOfAlllinkedPeople(person);//Iterate through each linked contact to fetch the phone numbersfor (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同步/“统一信息”地址簿联系人获取电话号码全部内容,希望文章能够帮你解决iphone – 从Facebook同步/“统一信息”地址簿联系人获取电话号码所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1001025.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存