Question

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?

No correct solution

OTHER TIPS

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);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top