Is there a way to ask user for Camera access after they have already denied it on iOS?

后端 未结 4 1094
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-07 12:35

I am using this code, but unfortunately it doesn\'t work.

After a user has denied camera access, I want to ask them for permission to use the camera again the next t

4条回答
  •  情歌与酒
    2020-12-07 12:43

    For Swift 3.0

    This will lead the user to settings for changing the permission.

    func checkCameraAuthorise() -> Bool {
        let status = AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo)
        if status == .restricted || status == .denied {
            let dialog = ZAlertView(title: "", message: "Please allow access to the camera in the device's Settings -> Privacy -> Camera", isOkButtonLeft: false, okButtonText: "OK", cancelButtonText: "Cancel", okButtonHandler:
                { _ -> Void in UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)}, cancelButtonHandler: { alertView in alertView.dismissAlertView() })
            dialog.show()
            return false
        }
        return true
    }
    

提交回复
热议问题