Skip to content

Instantly share code, notes, and snippets.

@funkydevil
Created March 26, 2015 11:36
Show Gist options
  • Save funkydevil/8b44027ad0df6bb95017 to your computer and use it in GitHub Desktop.
Save funkydevil/8b44027ad0df6bb95017 to your computer and use it in GitHub Desktop.
Check camera access
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == AVAuthorizationStatusAuthorized) {
// do your logic
} else if(authStatus == AVAuthorizationStatusDenied){
// denied
} else if(authStatus == AVAuthorizationStatusRestricted){
// restricted, normally won't happen
} else if(authStatus == AVAuthorizationStatusNotDetermined){
// not determined?!
[AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
if(granted){
NSLog(@"Granted access to %@", mediaType);
} else {
NSLog(@"Not granted access to %@", mediaType);
}
}];
} else {
// impossible, unknown authorization status
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment