if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined)//第一次讯问是否授权
{
ABAddressBookRequestAccessWithCompletion(self.addressBookRef, ^(bool granted, CFErrorRef error)
{
[HUD showUIBlockingIndicatorWithText:@"努力加载中"];
dispatch_async(dispatch_get_main_queue(), ^{
[self getContactsFromAddressBook];
});
});
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized)//已经授权
{
[HUD showUIBlockingIndicatorWithText:@"努力加载中"];
dispatch_async(dispatch_get_main_queue(), ^{
[self getContactsFromAddressBook];
});
}
else//拒绝
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"拒绝访问通讯录"
message:@"请打开 设置-隐私-通讯录 中打开喜搭搭应用的通讯录访问权限"
delegate:nil
cancelButtonTitle:@"确定"
otherButtonTitles:nil, nil];
[alert show];
}