2018-07-12 权限判断这块儿,是我不熟悉的地方

// 判断 麦克风的权限

#import 

    AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
    switch (authStatus) {
        case AVAuthorizationStatusNotDetermined:
            //没有询问是否开启麦克风
            NSLog(@"没有询问");
            break;
        case AVAuthorizationStatusRestricted:
            //未授权,家长限制
            NSLog(@"家长限制");
            break;
        case AVAuthorizationStatusDenied:
            //玩家未授权
            NSLog(@"玩家未授权");
            break;
        case AVAuthorizationStatusAuthorized:
            //玩家授权
            NSLog(@"授权开启");
            break;
        default:
            break;
    }

主动去申请马克风权限

#import 

    AVAudioSession *session = [AVAudioSession sharedInstance];
    
    [session performSelector:@selector(requestRecordPermission:) withObject:^(BOOL granted) {
        if (granted) {
            NSLog(@"打开授权");
        }
        else {
            NSLog(@"拒绝授权");
        }
        
    }
     ];

你可能感兴趣的:(2018-07-12 权限判断这块儿,是我不熟悉的地方)