ilia
ilia

Reputation: 1334

Can't request camera access

I have an app with camera access.
It was working as needed until recent times.
May be it is related to iOS10...

So, here is how I ask user for camera access:

- (void)checkCameraAuthorization {
    AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
    switch (status) {
        case AVAuthorizationStatusAuthorized: {
            break;
        }
        case AVAuthorizationStatusNotDetermined: {
            dispatch_suspend(self.sessionQueue);
            [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
                // never gets here
                dispatch_resume(self.sessionQueue);
            }];
            break;
        }
        default: {
            // denied or restricted;
            isAccessible = NO;
            [self inaccessibleCameraExit];
            break;
        }
    }
}

As I've said this code worked some time ago.

Now, it throws an exception after AVCaptureDevice requestAccessForMediaType: being executed.
If I comment out the call to this method, everything works except camera certainly.

enter image description here

Exception is not pointing to my code and not in my thread.

So, can you please help me to return camera to working state.

Upvotes: 0

Views: 77

Answers (1)

Rajat
Rajat

Reputation: 11127

You need to add NSCameraUsageDescription in your info.plist for iOS 10, this is the update from iOS 10.

For more information check this

Upvotes: 4

Related Questions