IOS user permissions

1

I'm making an app that asks for access to access the image gallery. So I have to ask the user for access.

My question is:

If the user the first time cancels the permissions, how can I ask them again?

At the moment I have this code that tells me if the permissions are enabled or not

if AVCaptureDevice.authorizationStatus(forMediaType: AVMediaTypeVideo) ==  AVAuthorizationStatus.authorized {
    //Están aceptados
}
else {
    AVCaptureDevice.requestAccess(forMediaType: AVMediaTypeVideo, completionHandler: { (granted :Bool) -> Void in
        if granted == true {
            //Los ha aceptado
        }
        else {
            //No los ha aceptado
        }
    })
}

Any possible solution?

    
asked by 22.11.2016 в 07:45
source

2 answers

2

ok, it's easy, in the else, add this so every time the user wants to use that functionality you will send them to change the configuration, this can be put in an alert view so that the user has the option to change the settings or simply continue without using the functionality.

let settingsUrl = URL(string: UIApplicationOpenSettingsURLString)
if UIApplication.shared.canOpenURL(settingsUrl) {
    UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
        print("Se abrieron las opciones")
      })
    }
}

SWIFT 3

let settingsUrl = URL(string: UIApplicationOpenSettingsURLString)
if UIApplication.shared.canOpenURL(settingsUrl!) {
   if #available(iOS 10.0, *) {
       UIApplication.shared.open(settingsUrl!, completionHandler: { (success) in
          print("Se abrieron las opciones")
       })
   } else {
        UIApplication.shared.openURL(settingsUrl!)
   }
}
    
answered by 22.11.2016 / 20:19
source
1

If you have already asked once, you will not request it again. The user has to go to settings and give him access permissions manually.

    
answered by 22.11.2016 в 11:15