Local contacts: Consider the local contacts when the access is authorized even if the server sync option is disabled.

This commit is contained in:
giomfo
2016-09-15 09:44:22 +02:00
parent 10b6ea615b
commit 48dcef6922
5 changed files with 96 additions and 12 deletions
@@ -1684,20 +1684,34 @@
{
self.isAddParticipantSearchBarEditing = YES;
searchBar.showsCancelButton = YES;
// Handle here local contacts
#ifdef MX_USE_CONTACTS_SERVER_SYNC
// If not requested yet, ask user permission to sync their local contacts
if (![MXKAppSettings standardAppSettings].syncLocalContacts && ![MXKAppSettings standardAppSettings].syncLocalContactsPermissionRequested)
{
[MXKAppSettings standardAppSettings].syncLocalContactsPermissionRequested = YES;
[MXKContactManager requestUserConfirmationForLocalContactsSyncInViewController:self completionHandler:^(BOOL granted) {
if (granted)
{
// Allow local contacts sync in order to add address book emails in search result
[MXKAppSettings standardAppSettings].syncLocalContacts = YES;
}
}];
if (granted)
{
// Allow local contacts sync in order to add address book emails in search result
[MXKAppSettings standardAppSettings].syncLocalContacts = YES;
}
}];
}
#else
// If not requested yet, ask user permission to access their local contacts
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
{
// Try to load the local contacts list
dispatch_async(dispatch_get_main_queue(), ^{
[[MXKContactManager sharedManager] loadLocalContacts];
});
}
#endif
return YES;
}