0

// Checking for authorization

PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];

if (status == PHAuthorizationStatusAuthorized) {
    // Access has been granted.

}
else if (status == PHAuthorizationStatusDenied) {
    // Access has been denied.

}
else if (status == PHAuthorizationStatusNotDetermined) {
    // Access has not been determined.
    [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
        if (status == PHAuthorizationStatusAuthorized) {
            // Access has been granted.

        }
        else {
            // Access has been denied.

        }
    }];
}
else if (status == PHAuthorizationStatusRestricted) {
    // Restricted access - normally won't happen.

}

I have set the keys in Info.plist both for Camera and Photos still getting the same result.

1 Answers1

0

You should use another method to check camera authorization status:

NSString *mediaType = AVMediaTypeVideo;
AVAuthorizationStatus authStatus = [AVCaptureDevice authorizationStatusForMediaType:mediaType];
if(authStatus == AVAuthorizationStatusAuthorized) {
  // do your logic
} else if(authStatus == AVAuthorizationStatusDenied){
  // denied
} else if(authStatus == AVAuthorizationStatusRestricted){
  // restricted, normally won't happen
} else if(authStatus == AVAuthorizationStatusNotDetermined){
  // not determined?!
  [AVCaptureDevice requestAccessForMediaType:mediaType completionHandler:^(BOOL granted) {
    if(granted){
      NSLog(@"Granted access to %@", mediaType);
    } else {
      NSLog(@"Not granted access to %@", mediaType);
    }
  }];
} else {
  // impossible, unknown authorization status
}

Link to related question

Community
  • 1
  • 1
skgwazap
  • 93
  • 1
  • 8