15 if ([AVCaptureDevice respondsToSelector:
@selector(requestAccessForMediaType: completionHandler:)])
17 [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted)
25 dispatch_sync(dispatch_get_main_queue(), ^{
26 NSLog(
@">> Camera permission granted");
31 NSLog(
@">> Camera permission denied");
37 NSLog(
@">> Camera permission granted");
43 AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
44 if(authStatus == AVAuthorizationStatusAuthorized)
46 NSLog(
@"Already granted access to %@", AVMediaTypeVideo);
48 else if(authStatus == AVAuthorizationStatusDenied)
50 NSLog(
@"Already denied access to %@", AVMediaTypeVideo);
51 }
else if(authStatus == AVAuthorizationStatusRestricted){
52 NSLog(
@"Already denied access to %@", AVMediaTypeVideo);
53 }
else if(authStatus == AVAuthorizationStatusNotDetermined){
55 [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
57 NSLog(
@"Granted access to %@", AVMediaTypeVideo);
59 NSLog(
@"Not granted access to %@", AVMediaTypeVideo);