title: iOS application asking the user two times to turn on location services when trying to access location with the location services turned off
body: <p>I am trying to fetch user location at one button click in my iOS application. I am using below code to initiate the location manager.</p>
  
  <pre><code>locationManager = [[CLLocationManager alloc] init];
  locationManager.delegate = self;
  locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
  locationManager.distanceFilter = 1000;
  
  if ([CLLocationManager locationServicesEnabled]) {
      [locationManager startUpdatingLocation];
  }
  else{
      UIAlertView *alert= [[UIAlertView alloc]initWithTitle:@"Error" message:@"The location     services seems to be disabled from the settings." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles: nil];
      [alert show];
      alert= nil;
  }
  </code></pre>
  
  <p>When the location services is turned on and the user is clicking the button, then it's working fine and the location is fetching correctly. </p>
  
  <p>But when the location services is off and user tries to click the button, as per my code he alert should display as above. But before it reaches else loop, iOS displays a system level pop-up like below.</p>
  
  <p><img src="https://i.stack.imgur.com/ckq7c.png" alt="enter image description here"></p>
  
  <p>On top of this system level alert view, my own alert view is getting displayed. This is pretty frustrating. The problem is that if the user cancels the system level pop-up instead of going to settings and tries to click the button, second time also same thing (two alerts scenario) is happening. However, if the user continues the same step, then the system level alert is not displayed now. That means the system level pop-up as displayed above is coming for 2 times only and after that nothing is happening. How to handle this scenario. Please help.</p>