CNContactViewControllerDelegate Not Called

I'm pushing to a `CNContactViewController` for existing contact with `viewControllerForContact` (having set the `contactStore` and the `delegate`, but although I've implemented the `CNContactViewControllerDelegate` methods, they're not getting called. I'm seeing the contact presented fine, but if I tap on any of the properties, I see the following error:


2015-08-13 01:29:38.964 MyApp[2468:869879] plugin com.apple.MobileAddressBook.ContactViewViewService interrupted

2015-08-13 01:29:38.965 MyApp[2468:869879] plugin com.apple.MobileAddressBook.ContactViewViewService invalidated

2015-08-13 01:29:38.978 MyApp[2468:869838] viewServiceDidTerminateWithError:: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "(null)" UserInfo={Message=Service Connection Interrupted}


But it never calls my `shouldPerformDefaultActionForContactProperty` delegate method, and after a few seconds the screen goes blank (the contact disappears).


Any ideas?


For the sake of completeness, here is my code:



- (IBAction)didTapButton:(id)sender {
    self.store = [[CNContactStore alloc] init];
    [self.store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError *error) {
        if (granted) {
            NSPredicate *predicate = [CNContact predicateForContactsMatchingName:@"John"];
            NSError *error;
            NSArray *contacts = [self.store unifiedContactsMatchingPredicate:predicate keysToFetch:@[[CNContactViewController descriptorForRequiredKeys]] error:&error];
            NSAssert(contacts, @"%@", error);
           
            NSLog(@"%ld", (long) [contacts count]);
           
            dispatch_async(dispatch_get_main_queue(), ^{
                CNContactViewController *controller = [CNContactViewController viewControllerForContact:contacts[0]];
                controller.contactStore = self.store;
                controller.delegate = self;
                [self.navigationController pushViewController:controller animated:TRUE];
            });
        } else {
            NSLog(@"requestAccessForEntityType error: %@", error);
        }
    }];
}


- (BOOL)contactViewController:(nonnull CNContactViewController *)viewController shouldPerformDefaultActionForContactProperty:(nonnull CNContactProperty *)property {
    NSLog(@"%s", __FUNCTION__);
   
    return FALSE;
}

- (void)contactViewController:(nonnull CNContactViewController *)viewController didCompleteWithContact:(nullable CNContact *)contact {
    NSLog(@"%@", contact);
}

Replies

Souns like the same issue that is discussed here: https://forums.developer.apple.com/thread/12275

Yep, that sounds related. That's about the picker and this is about the contact view controller (which explains why I didn't find that one when I searched for answers), but it sounds like they're suffering from remarkably similar problems.

This issue appears to resolved in today's Xcode 7 GM seed (7A218) at https://developer.apple.com/xcode/download/

I download Xcode 7 GM seed (7A218) but i couldnt still call delegate. Could you help me, please? is it fix this bug?

I have same trouble.


I have tested iOS 9.1 and Xcode 7.1.


I found that the error occures for the contact which has email connected to Apple ID. FaceTime/Audio button is activated on Contacts.app, the contact can't display.


I wanna know the solution.