Код: Выделить всё
(IBAction)seeSystemContacts:(id)sender {
if ([self fullAccessToSystemContacts]) {
[self launchImportContactsVC];//This takes user to a VC where they can see contacts
}
else { //Following launches a dialog with two options
[[Utilities shared] getUserInputOnVC:self
title:@"See Contacts"
body:@"Allow app to access your contacts in Settings" buttons:@[@"Not now", @"Settings"] completion:^(NSInteger choice){
if (choice==1) {
//That would be Go to Settings
[self gotoSettings];
}
else {
//Not now
//Third Fallback if they click Not Now, show them contactPicker option
[[ContactPicker shared] openContactPickerOnViewController:self completion:^(NSArray *contacts){
[self.fetchedResultsController performFetch:nil];
[self.tableView reloadData];
}];
}
}];
}
}
-(BOOL)fullAccessToSystemContacts {
CNContactStore *store = [[CNContactStore alloc] init];
CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
if (status == CNAuthorizationStatusAuthorized) {
return YES;
}
return NO;
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... project-in