iOS-请求系统麦克风(话筒)的方法

- (void)noCanRecorded{

UIAlertController*alterC = [UIAlertControlleralertControllerWithTitle:@"麦克风被禁用"message:@"您可点击去设置,开启麦克风权限"preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction*gotoSetting = [UIAlertActionactionWithTitle:@"去设置"style:UIAlertActionStyleDestructivehandler:^(UIAlertAction*_Nonnullaction) {

if(kSYSTEM_VERSION_LESS_THAN(@"10")) {

NSURL*url= [NSURLURLWithString:@"prefs:root=Privacy&path=MICROPHONE"];

if([[UIApplicationsharedApplication]canOpenURL:url]) {

[[UIApplicationsharedApplication]openURL:url];

}

}else{

NSURL*url = [NSURLURLWithString:UIApplicationOpenSettingsURLString];

if([[UIApplicationsharedApplication]canOpenURL:url]) {

[[UIApplicationsharedApplication]openURL:urloptions:@{}completionHandler:^(BOOLsuccess) {

}];

}

}

}];

UIAlertAction*cancel = [UIAlertActionactionWithTitle:@"知道了"style:UIAlertActionStyleCancelhandler:^(UIAlertAction*_Nonnullaction) {

}];

[alterCaddAction:gotoSetting];

[alterCaddAction:cancel];

[selfpresentViewController:alterCanimated:YEScompletion:nil];

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容