```
//定位权限
if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {
[self initerrorAlertView];
return;
}else{
NSLog(@"打开");
}
//相册权限
ALAuthorizationStatus author = [ALAssetsLibraryauthorizationStatus];
if (author == ALAuthorizationStatusRestricted || author ==ALAuthorizationStatusDenied){
//无权限
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请在\"隐私\"里开启照片权限" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
return;
}
//相机权限
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)
{
//无权限
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请在\"隐私\"里开启相机权限" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
return;
}
//麦克风权限
AVAudioSession *avSession = [AVAudioSession sharedInstance];
if ([avSession respondsToSelector:@selector(requestRecordPermission:)]) {
[avSession requestRecordPermission:^(BOOL available) {
if (available) {
//completionHandler
}
else
{
dispatch_async(dispatch_get_main_queue(), ^{
[[[UIAlertView alloc] initWithTitle:@"无法录音" message:@"请在“设置-隐私-麦克风”选项中开启权限" delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] show];
return ;
});
}
}];
}
//用户通知开关
if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone) {
已关闭;
}else
已开启;
```