The contact book is used to search for users by email or phone number on Riot.

- Update `NSContactsUsageDescription` to turn on by default the matrix user discovering when the user allows the access to the local contacts.

- Ask to the existing users the permission to upload emails when the contact access is already granted.

- Update matrix ids for all the local contacts in only one request when device contacts are loaded and an identity server is available.
This commit is contained in:
giomfo
2017-01-05 15:44:00 +01:00
parent 40e50e1420
commit cfaa041d0d
6 changed files with 50 additions and 93 deletions
@@ -860,39 +860,17 @@
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
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)
{
// 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
// Check whether the access to the local contacts has not been already asked.
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)
{
// Try to load the local contacts list
dispatch_async(dispatch_get_main_queue(), ^{
[[MXKContactManager sharedManager] loadLocalContacts];
});
// Allow by default the local contacts sync in order to discover matrix users.
// This setting change will trigger the loading of the local contacts, which will automatically
// ask user permission to access their local contacts.
[MXKAppSettings standardAppSettings].syncLocalContacts = YES;
}
#endif
self.isAddParticipantSearchBarEditing = YES;
searchBar.showsCancelButton = NO;
return YES;
}