Okay, I know that there are many question about it, but they are all from many time ago.
So. I know that it is possible because the Map app does it.
In the M
Add this to your class,
public class func showSettingsAlert(title:String,message:String,onVC viewController:UIViewController,onCancel:(()->())?){
YourClass.show2ButtonsAlert(onVC: viewController, title: title, message: message, button1Title: "Settings", button2Title: "Cancel", onButton1Click: {
if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString){
UIApplication.sharedApplication().openURL(settingsURL)
}
}, onButton2Click: {
onCancel?()
})
}
public class func show2ButtonsAlert(onVC viewController:UIViewController,title:String,message:String,button1Title:String,button2Title:String,onButton1Click:(()->())?,onButton2Click:(()->())?){
dispatch_async(dispatch_get_main_queue()) {
let alert : UIAlertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: button1Title, style:.Default, handler: { (action:UIAlertAction) in
onButton1Click?()
}))
alert.addAction(UIAlertAction(title: button2Title, style:.Default, handler: { (action:UIAlertAction) in
onButton2Click?()
}))
viewController.presentViewController(alert, animated: true, completion: nil)
}
}
Call like this,
YourClass.showSettingsAlert("App would like to access camera", message: "App would like to access camera desc", onVC: fromViewController, onCancel: {
print("canceled")
})