-1

I have an app that want to get user location. As you may know, Apple change user private policy (as i suggest) and, now i can't get user location. It show no error, no warning, nothing. In attempt to fix this i add following code before calling [_locationManager startUpdatingLocation]; There it is:

CLAuthorizationStatus authStatus = [CLLocationManager authorizationStatus];

    if (authStatus == kCLAuthorizationStatusNotDetermined) {
        [_locationManager requestWhenInUseAuthorization];
        NSLog(@"Case 1");
        return;
    };

    if (authStatus == kCLAuthorizationStatusDenied || authStatus == kCLAuthorizationStatusRestricted) {
        // show an alert
        NSLog(@"Case 2");
        return;
    };

And output is Case 1, which mean - authStatus == kCLAuthorizationStatusNotDetermined. But there is no alert, no prompt, no suggestion to user to enable location services for my app. Actually, i even turn it on manually in settings of my iPhone. Still, not working (it work perfectly before Xcode update).

How to fix that? Any advices would be appreciated, thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
  • You should always call `requestWhenInUseAuthorization` so remove the if statements. Also, have you added the required key to your info.plist? – Paulw11 Sep 27 '14 at 21:32
  • possible duplicate of [Xcode 6 GM - CLLocationManager](http://stackoverflow.com/questions/25844430/xcode-6-gm-cllocationmanager) – Bhumit Mehta Sep 27 '14 at 21:52
  • Find descriptive solution at http://datacalculation.blogspot.in/2014/11/how-to-fix-cllocationmanager-location.html – iOS Test Nov 02 '14 at 17:19

1 Answers1

3

You need to add a reasoning in your info.plist as to why you are going to request a users location.

Open info.plist add a row with a key of NSLocationWhenInUseUsageDescription or NSLocationAlwaysUsageDescription, a type of String, and for the value type in why you want to request the users location. For example, "Uses location to calculate the sunrise and sunset". iOS will not ask a user for permission to use their location unless you have given a reason as to why you are requesting it.

TyloBedo
  • 495
  • 2
  • 12
  • For more description you may visit http://datacalculation.blogspot.in/2014/11/how-to-fix-cllocationmanager-location.html – iOS Test Nov 02 '14 at 17:20