系統(tǒng)權(quán)限

```

//定位權(quán)限

if([CLLocationManager locationServicesEnabled] && [CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) {

[self initerrorAlertView];

return;

}else{

NSLog(@"打開");

}

//相冊權(quán)限

ALAuthorizationStatus author = [ALAssetsLibraryauthorizationStatus];

if (author == ALAuthorizationStatusRestricted || author ==ALAuthorizationStatusDenied){

//無權(quán)限

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"請?jiān)赲"隱私\"里開啟照片權(quán)限" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"確定", nil];

return;

}

//相機(jī)權(quán)限

AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];

if (authStatus == AVAuthorizationStatusRestricted || authStatus ==AVAuthorizationStatusDenied)

{

//無權(quán)限

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"請?jiān)赲"隱私\"里開啟相機(jī)權(quán)限" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"確定", nil];

return;

}

//麥克風(fēng)權(quán)限

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:@"請?jiān)凇霸O(shè)置-隱私-麥克風(fēng)”選項(xiàng)中開啟權(quán)限" delegate:nil cancelButtonTitle:@"確定" otherButtonTitles:nil] show];

return ;

});

}

}];

}

//用戶通知開關(guān)

if ([[UIApplication sharedApplication] enabledRemoteNotificationTypes] == UIRemoteNotificationTypeNone) {

已關(guān)閉;

}else

已開啟;

```

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容