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
@@ -801,13 +801,15 @@
self.isAddParticipantSearchBarEditing = YES;
searchBar.showsCancelButton = NO;
// Handle here local contacts
#ifdef MX_USE_CONTACTS_SERVER_SYNC
if (![MXKAppSettings standardAppSettings].syncLocalContacts)
{
// 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)
{
@@ -817,6 +819,18 @@
}];
}
}
#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;
}