Skip to content

Instantly share code, notes, and snippets.

@qy1010
Last active January 8, 2020 11:59
Show Gist options
  • Save qy1010/0cf6d307488cfce2eb09c9160b97a581 to your computer and use it in GitHub Desktop.
Save qy1010/0cf6d307488cfce2eb09c9160b97a581 to your computer and use it in GitHub Desktop.
+ (void)checkCameraPermission:(void(^)(BOOL status))block
{
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];//读取设备授权状态
if (authStatus == AVAuthorizationStatusRestricted || authStatus == AVAuthorizationStatusDenied) {
if (block) {
block(NO);
}
return;
}
else if (authStatus == AVAuthorizationStatusNotDetermined) {
if (block) {
block(NO);
}
}
else if (authStatus == AVAuthorizationStatusAuthorized) {
if (block) {
block(YES);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment