1

Possible Duplicate:
CLLocation ask again for permission
How to prompt user to turn on Location Services…again

I would like to have the "use your current location" alert to keep prompting if the user says "no".

Currently in the app I'm working on, if the user says "no" the prompt never shows again. I'm wondering how to keep the prompt/alert alive if they return to the view controller.

thanks for any help

Community
  • 1
  • 1
hanumanDev
  • 6,592
  • 11
  • 82
  • 146

2 Answers2

8

I'm pretty sure it is designed to ask only once (and for good reason). You can check if location services are enabled for your app and pop a message like "Please enable location services...".

Edit: you can check if location services are enabled with

[CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized
Vatev
  • 7,493
  • 1
  • 32
  • 39
4

Corelocationmanager will fire - (void)locationManager:didFailWithError:(NSError *)error whenever you try to call methods like startUpdatingLocation. So you can check whether user has denied Location monitoring using the following code.

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
      if([error code] == kCLErrorDenied){
        //Alert view
      }
}

You can enable the Corelocation alert again by resetting location warnings. Go to Settings > General > Reset > Reset Location Warnings. Also you can add alertview asking the user to direct to Settings Application and reset location warning there. Use following code inside Alert view delegate to open Settings Application.

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]];
rakeshNS
  • 4,227
  • 4
  • 28
  • 42