我正在创建一个将联系人保存到地址簿的应用程序,但是当我将ABAddressBookCreate用于我的代码时,它会显示为警告.我在iOS 7编码.
我的问题是,iOS 7中ABAddressBookCreate的替代品是什么.
任何帮助将不胜感激.谢谢.
我使用以下方法检索所有联系人
- (void)getAllContacts:(void(^)(NSArray *array))handler
{
CNAuthorizationStatus status = [CNContactStore authorizationStatusForEntityType:CNEntityTypeContacts];
if (status == CNAuthorizationStatusDenied || status == CNAuthorizationStatusDenied)
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"This app previously was refused permissions to contacts; Please go to settings and grant permission to this app so it can use contacts" preferredStyle:UIAlertControllerStyleAlert];
[alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
[self presentViewController:alert animated:TRUE completion:nil];
return;
}
CNContactStore *store = [[CNContactStore alloc] init];
[store requestAccessForEntityType:CNEntityTypeContacts completionHandler:^(BOOL granted, NSError * _Nullable error) {
// make sure the user granted …Run Code Online (Sandbox Code Playgroud)