문제

I am trying to compare the emails of a selected phone contact to the emails of registered users in my app to see if they are registered.

It should be simple enough. Get the recordRef, copy the email multiValue, then compare:

-(void) checkForUser:(ABRecordRef) person {

    ABMultiValueRef contactEmails = ABRecordCopyValue(person, kABPersonEmailProperty);
    NSLog(@"emails are %@", contactEmails); // seeing error in log

    ...
    // check the emails against registered users. 

This works great most of the time. Problem comes with unified contacts. My contact for example is a unified record with my Facebook, home, work emails all in one contact. When I run checkUser: with that ABRecordRef it is ONLY showing my Facebook email even though there are 4 others.

I am thinking this is a bug. Am I missing something about unified cards?

올바른 솔루션이 없습니다

다른 팁

This is what I did, you can see if your code is similar - if so no more info to provide you:

ABMutableMultiValueRef multiValue = ABRecordCopyValue(person, kABPersonEmailProperty);
//CFShow(multiValue);
if(multiValue) {
    for(CFIndex j=0; j<ABMultiValueGetCount(multiValue); ++j) {
        //CFShow(ABMultiValueCopyLabelAtIndex(multiValue, j) );
        CFStringRef label = ABMultiValueCopyLabelAtIndex(multiValue, j);
        if(![emailKey isEqualToString:(__bridge NSString *)label]) {
            CFRelease(label);
            continue;
        }
        CFRelease(label);

        CFStringRef string = ABMultiValueCopyValueAtIndex(multiValue, j);
        NSString *finalStr = CFBridgingRelease(string);

        NSArray *array = [finalStr componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
        if([array count] == 3)  finalStr = (NSString *)[array objectAtIndex:1];

        [data replaceObjectAtIndex:emailAddress withObject:finalStr];
        break;
    }
    CFRelease(multiValue);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top