ABRecordCopyValue return 0 ?

2019-03-03 10:59发布

What I trying to do, is get all contacts and relies if the contact have SocialProfileProperty or not, after get all this contacts that have SocialProfileProperty I will make simple filtration to know if it is Facebook,Twitter,..

Before I post this question I west full day trying to find any solution for this problem ??

But it is allows return 0 ??

ABAddressBookRef addressBook;
CFErrorRef *erer = NULL;
addressBook = ABAddressBookCreateWithOptions(NULL, erer);
CFArrayRef _allPeople = ABAddressBookCopyArrayOfAllPeople(addressBook);
CFIndex _nPeople = ABAddressBookGetPersonCount(addressBook);
NSMutableArray *socialArray = [[NSMutableArray alloc] init];
ABMultiValueRef socialProfiles;
for (int i=0;i<_nPeople; i++) {
    ABRecordRef _person=CFArrayGetValueAtIndex( _allPeople,i);
    NSNumber *recordId = [NSNumber numberWithInteger:ABRecordGetRecordID(_person)];
    NSLog(@"%@",recordId);
    socialProfiles = ABRecordCopyValue(_person, kABPersonSocialProfileProperty);
    if (ABMultiValueGetCount(socialProfiles)>0) {
        [socialArray addObject:(__bridge id)(socialProfiles)];
    }
}
NSLog(@"%d",socialArray.count);

1条回答
老娘就宠你
2楼-- · 2019-03-03 11:31

It is allows return 0 ,until the user marge the Social contacts with native and this does

not happened until he try to delete the Facebook account for example in that case alert appear

and ask if u wanna to marge contacts or not ??? other wise return 0 values :)

So this method will never work until the user marge the FaceBook Contacts with native contacts.

查看更多
登录 后发表回答