Created
March 26, 2015 11:36
-
-
Save funkydevil/8b44027ad0df6bb95017 to your computer and use it in GitHub Desktop.
Check camera access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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