Promt User for Location – iOS8

| | August 6, 2015

In my view didLoadMethod I have

locationManager = [[CLLocationManager alloc]init]; // initializing locationManager
    locationManager.delegate = self; // we set the delegate of locationManager to self.
    locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [locationManager startUpdatingLocation];


    if([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
        [locationManager requestWhenInUseAuthorization];
    }

And the request is called, but the user is not prompted? why?

Thanks

One Response to “Promt User for Location – iOS8”

  1. You probably need to update your plist file. Here’s a tutorial how to do it:

    http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/

    Quick & dirty:

    You need to do is to add one or both of the following keys to your Info.plist file:

    NSLocationWhenInUseUsageDescription
    
    NSLocationAlwaysUsageDescription
    

    You also need to request authorization for the corresponding location method, WhenInUse or Background. Use one of these calls:

    [self.locationManager requestWhenInUseAuthorization]
    [self.locationManager requestAlwaysAuthorization]
    

    There’s also a post that I found helpful:

    Location Services not working in iOS 8

    This answer details how to update your plist file:

    http://stackoverflow.com/a/24064860/4475605

    Add the following lines to your info.plist

    <key>NSLocationWhenInUseUsageDescription</key>
    <string>The spirit of stack overflow is coders helping coders</string>
    
    <key>NSLocationAlwaysUsageDescription</key>
    <string>I have learned more on stack overflow than anything else</string>
    

Leave a Reply