2

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.

Jagat Dave
  • 1,643
  • 3
  • 23
  • 30
  • 1
    Can you pls share code, I am getting permission pop-up on iOS 12 – Sohil R. Memon Oct 03 '18 at 08:10
  • You can check `AVCaptureDevice.authorizationStatus` first. If it's not authorized ask manually by: `AVCaptureDevice.requestAccess` – Jurasic Oct 03 '18 at 08:11
  • Another similar question was asked not long ago: https://stackoverflow.com/questions/52622390/popup-is-not-coming-to-ask-permission-to-access-camera-in-ios-12. could be a bug – Scriptable Oct 03 '18 at 08:17
  • there is a change, it will ask for permission only if you want to save... Apple policy is changed... – Fahim Parkar Oct 03 '18 at 08:19
  • @Scriptable agree with you. – Jagat Dave Oct 03 '18 at 09:25
  • @SohilR.Memon Yes...Sure. – Jagat Dave Oct 03 '18 at 09:32
  • Yes, I am also facing the same issue, my app got rejected due to accessing privacy sensitive data and they said i did not included NSCameraUsageDescription in plist. But it was there in the project, and it is not popping up the default permission alert. – R. Mohan Dec 02 '18 at 06:04

0 Answers0