So here is the function you should use. You should call this function, before you start recording and check if there is necessary permission.
– (void)requestCameraPermissionsIfNeeded {
NSLog(@”requestCameraPermissionsIfNeeded”);
// check camera authorization status
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
switch (authStatus) {
case AVAuthorizationStatusAuthorized: { // camera authorized
NSLog(@”requestCameraPermissionsIfNeeded camera authorized”);
// do camera intensive stuff
}
break;
case AVAuthorizationStatusNotDetermined: { // request authorization
NSLog(@”requestCameraPermissionsIfNeeded have to ask user again”);
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
dispatch_async(dispatch_get_main_queue(), ^{
if(granted) {
// do camera intensive stuff
} else {
NSLog(@”STOP RECORDING”);
WeAreRecording = NO;
ShareVideo = YES;
[MovieFileOutput stopRecording];
//Prompt message to user.
}
});
}];
}
break;
case AVAuthorizationStatusRestricted:{
NSLog(@”STOP RECORDING”);
WeAreRecording = NO;
ShareVideo = YES;
[MovieFileOutput stopRecording];
//Prompt message to user.
}
case AVAuthorizationStatusDenied: {
NSLog(@”STOP RECORDING”);
WeAreRecording = NO;
ShareVideo = YES;
[MovieFileOutput stopRecording];
//Prompt message to user.
dispatch_async(dispatch_get_main_queue(), ^{
});
}
break;
default:
break;
}
}
This will help you in identifying issue and display proper message to user.