Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location Services not working in iOS 8

My app that worked fine on iOS 7 doesn't work with the iOS 8 SDK.

CLLocationManager doesn't return a location, and I don't see my app under Settings -> Location Services either. I did a Google search on the issue, but nothing came up. What could be wrong?

like image 290
özg Avatar asked Jun 05 '14 14:06

özg


People also ask

Why is Location Services not working on my iPhone?

Enable Location Services In general, the most common reason for “Share My Location” feature not working on iPhone is due to Location Services being disabled. Go to Settings > Privacy > tap on Location Services. On the Location services screen, make sure that the option for Location Services is turned ON.

How do I fix my location on my iPhone 8?

If you can't find your current location on your iPhone, iPad, or iPod touch. Turn on Location Services and Location Access for Maps. In the Settings app, tap Privacy, then tap Location Services. Make sure Location Services is on, and make sure Maps is set to While Using the App or Widgets.

How do I fix Location Services?

Step 1: Open the Settings app on your phone and scroll down to tap on Location. Step 2: Go to Location services and tap on Google Location Accuracy. Step 3: Toggle on Improve Location Accuracy. Once enabled, check to see if location accuracy has improved by using an app like Google Maps.


2 Answers

I ended up solving my own problem.

Apparently in iOS 8 SDK, requestAlwaysAuthorization (for background location) or requestWhenInUseAuthorization (location only when foreground) call on CLLocationManager is needed before starting location updates.

There also needs to be NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription key in Info.plist with a message to be displayed in the prompt. Adding these solved my problem.

enter image description here

For more extensive information, have a look at: Core-Location-Manager-Changes-in-ios-8

like image 56
özg Avatar answered Oct 26 '22 13:10

özg


I was pulling my hair out with the same problem. Xcode gives you the error:

Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.

But even if you implement one of the above methods, it won't prompt the user unless there is an entry in the info.plist for NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription.

Add the following lines to your info.plist where the string values represent the reason you you need to access the users location

<key>NSLocationWhenInUseUsageDescription</key> <string>This application requires location services to work</string>  <key>NSLocationAlwaysUsageDescription</key> <string>This application requires location services to work</string> 

I think these entries may have been missing since I started this project in Xcode 5. I'm guessing Xcode 6 might add default entries for these keys but have not confirmed.

You can find more information on these two Settings here

like image 35
Henry Avatar answered Oct 26 '22 13:10

Henry