The problem I am facing is that when I press a UIButton - location services are required to initiate the action. However if the user was to deny Location Services at the initial launch of the app - the app will crash.
I have tried finding a way to implement CLAuthorizationStatus .Denied but I can't seem to find a way to do so. The only code I can seem to implement is the didChangeAuthorizationStatus which only initiates the request at First Launch of the application.
func locationManager(manager: CLLocationManager, didChangeAuthorizationStatus status: CLAuthorizationStatus)
{
if status == .AuthorizedAlways || status == .AuthorizedWhenInUse
{
manager.startUpdatingLocation()
}
else
{
manager.requestWhenInUseAuthorization()
}
}
If I press the UIButton to send the API Request the app will crash if location services have been denied.
My question is how can I implement a method, within the button's IBAction, that will direct the user to go to their settings and enable location services. :)