In iOS 11 when the app is launch first time and I will click on the button of the camera then it will show the dialog box of Camera Permission.
But in iOS 12 when I click on camera button it with directly open the camera without any permission.
I have already added Privacy - Camera Usage Description
in my Info.plist
file.
I am confused what to do? Please give me some solution.
+(void)checkPermissionForCameraWithSuccess:(void (^) (void))successHandler failure:(void (^) (void))failureHandler
{
AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
switch (status)
{
case AVAuthorizationStatusRestricted:
case AVAuthorizationStatusDenied:{
if (failureHandler)
dispatch_async (dispatch_get_main_queue (), ^{ failureHandler (); });
}; break;
case AVAuthorizationStatusAuthorized:{
if (successHandler)
dispatch_async (dispatch_get_main_queue (), ^{ successHandler (); });
}; break;
case AVAuthorizationStatusNotDetermined:
{
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
if (!granted)
{
if (failureHandler) {
dispatch_async (dispatch_get_main_queue (), ^{ failureHandler (); });
}
} else {
if (successHandler) {
dispatch_async (dispatch_get_main_queue (), ^{ successHandler (); });
}
}
}];
break;
}
default:
break;
}
}
Note: By default, it will return status = AVAuthorizationStatusAuthorized
without any permission dialog box.