Settings> Contacts> The default account is selected as iCloud and a new connection is saved. Then the default account as gmail changed. CNContactStore does not retrieve a new saved contact.
CNContactStore *store = [[CNContactStore alloc] init]; [store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) { if (granted == YES) { NSArray *keys = @[CNContactFamilyNameKey, CNContactGivenNameKey, CNContactPhoneNumbersKey, CNContactImageDataKey,CNContactEmailAddressesKey]; NSArray * contactContainerArray = [store containersMatchingPredicate:nil error:nil]; for(CNContainer * container in contactContainerArray) { NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:container.identifier]; NSError *error; NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error]; }
source share