-1

I am creating an application that gives users the option to upload a profile picture. I am using Fusuma as a third party substitute for UIImagePickerController. It has a bug that is requiring me to ask for camera and photo library permission before presenting the image picking view controller (FusumaViewController). I am able to request photo library permission via PHPhotoLibrary.requestAuthorization { (status) in }, but when the image picking view controller is presented, it then asks for camera access. I'm wanting to request access to both the camera and the photo library at the same time, is this possible?

David Chopin
  • 2,780
  • 2
  • 19
  • 40

1 Answers1

0

Per rmaddy's qualified comment, you cannot request both at the same time. Still, I figured I would share how I present the two requests back-to-back, which is about as good as we can get.

import UIKit
import Photos

class SomeViewController: UIViewController {

    ...

    @IBAction func requestAccessButtonPressed(_ sender: Any) {
        PHPhotoLibrary.requestAuthorization { (status) in

            //Use PHAuthorizationStatus as you need here

            AVCaptureDevice.requestAccess(for: AVMediaType.video) { response in 

                //Use the boolean "response", which tells us whether the user granted photo access here

            }
        }
    }
}
David Chopin
  • 2,780
  • 2
  • 19
  • 40