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];

}

你可能感兴趣的:(iOS-请求系统麦克风(话筒)的方法)