1

I have an app which has location service enabled. But it doesn't have the option "while using the app" even the app's SDK is iOS 8.2. Does anyone know how to fix it? Thanks in advance!

jww
  • 97,681
  • 90
  • 411
  • 885
JohnnL
  • 111
  • 11

2 Answers2

1

In order to support both "While Using the App" and "Always" authorization in your app's Location settings, you must call both [CLLocationManager requestWhenInUseAuthorization] and [CLLocationManager requestAlwaysAuthorization] at some point in your app.

Remember that despite requesting authorization twice, only one alert dialog will be presented to the user per install of the app, corresponding to the authorization type you request first. The only way for the user to subsequently update the status is via the Settings app.

markdanyo
  • 31
  • 1
  • Thanks Mark. Though, it didn't make the option "While Using the App" appearing in the location service. I found the answer that simply requires a key in info.plist - NSLocationWhenInUseUsageDescription. I posted an answer underneath. – JohnnL Mar 23 '15 at 01:14
0

I found the answer from another post. Basically, I need to add the following key to the info.plist file:

NSLocationWhenInUseUsageDescription

Also, the following code needs to be called:

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
    [self.locationManager requestWhenInUseAuthorization];
}
Pang
  • 9,564
  • 146
  • 81
  • 122
JohnnL
  • 111
  • 11
  • I got the answer from: http://stackoverflow.com/questions/24062509/location-services-not-working-in-ios-8 and http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/ – JohnnL Mar 23 '15 at 01:16