0

I have created my code for the authorizations of photos and camera but fore some reason the code runs but never is displayed in the privacy settings. I am clearly missing something but I'm been trying to work it out for almost 12 hours and can't find it out. Is there like a checklist that needs for all options to be ticked before the permission shows up in the privacy settings.

override func viewDidAppear(animated: Bool) {
    super.viewDidAppear(animated)

    if PHPhotoLibrary.authorizationStatus() != PHAuthorizationStatus.Authorized {

        PHPhotoLibrary.requestAuthorization({(status: PHAuthorizationStatus) in

            let settings = NSURL(string: UIApplicationOpenSettingsURLString)

            // Create the alert controller
            let alertController = UIAlertController(title: "Access Photos", message: "ClubVIP requires access to your Photos, please enable access in Privacy Settings.", preferredStyle: .Alert)

            // Create the actions
            let privacySettingsAction = UIAlertAction(title: "Settings", style: UIAlertActionStyle.Default) {
                UIAlertAction in

                //Take to Privacy Settings
                UIApplication.sharedApplication().openURL(settings!)

            }

            let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
                UIAlertAction in
                NSLog("")
            }


            // Add the actions
            alertController.addAction(privacySettingsAction)
            alertController.addAction(cancelAction)

            // Present the controller
            self.presentViewController(alertController, animated: true, completion: nil)

        })
    }

    if AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo) != AVAuthorizationStatus.Authorized {

        let settings = NSURL(string: UIApplicationOpenSettingsURLString)
        //let settings = NSURL(string: UIApplicationOpen)

        AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { granted in

            if !granted {

                // Create the alert controller
                let alertController = UIAlertController(title: "Access Camera", message: "Access to your Camera has been denied, please enable access in Privacy Settings.", preferredStyle: .Alert)

                // Create the actions
                let privacySettingsAction = UIAlertAction(title: "Settings", style: UIAlertActionStyle.Default) {
                    UIAlertAction in

                    //Take to Privacy Settings
                    UIApplication.sharedApplication().openURL(settings!)

                }


                // Add the actions
                alertController.addAction(privacySettingsAction)

                // Present the controller
                self.presentViewController(alertController, animated: true, completion: nil)

            }


        })

    }

}

0 Answers0