系统权限

```

//定位权限

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

已开启;

```

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • #import<Foundation/Foundation.h> #import #import "sqlTest...
    lichengjin阅读 3,161评论 0 0
  • APP开发避免不开系统权限的问题,如何在APP以更加友好的方式向用户展示系统权限,似乎也是开发过程中值得深思的一件...
    亮仔菲个阅读 5,353评论 0 0
  • 需要引用到的头文件有 相册权限 照相机权限 麦克风权限 通知权限 定位权限 通讯录权限
    SincereDu阅读 3,199评论 0 0
  • 发热放入Android6.0带来了新的权限管理方式,根据提供的官方文档,再加上自己的理解,做了以下汇总仅供大家伙参...
    PapiAP阅读 5,721评论 0 6
  • https://developer.android.com/guide/topics/security/permi...
    Sinchunk阅读 4,093评论 0 0

友情链接更多精彩内容