Currently I am using this code snippet to fetch contact from iPhone
CNContactStore *store = [[CNContactStore alloc] init];
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted == YES) {
//keys with fetching properties
NSArray *keys = @[CNContactGivenNameKey,CNContactFamilyNameKey, CNContactPhoneNumbersKey, CNContactImageDataKey];
[[CNContactsUserDefaults sharedDefaults] sortOrder];
NSString *containerId = store.defaultContainerIdentifier;
//NSComparator hg= [CNContact comparatorForNameSortOrder:CNContactSortOrderGivenName];
NSPredicate *predicate = [CNContact predicateForContactsInContainerWithIdentifier:containerId];
NSError *error;
NSArray *cnContacts = [store unifiedContactsMatchingPredicate:predicate keysToFetch:keys error:&error];
NSSortDescriptor *sortDescriptor;
sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"givenName"
ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor];
NSArray *sortedArray = [cnContacts sortedArrayUsingDescriptors:sortDescriptors];
}];
but here i am only getting contacts from iCloud.
how can i get contact from Facebook, gmail, or any other cloud? please help regard this.
I spent 2 days for this issue but didn't get any solution.
Then done that with one patch. This is worked for me.