7

Hullo, I am starting to port my apps to iOS 8 and I soon bounced into a problem with CLLocationManager. Basically the app no longer centers the map on the user's location and instead proposed error:

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

Executing

 [CLLocationManager requestAlwaysAuthorization]

does nothing and even inserting the NSLocationAlwaysUsageDescription key in the app’s Info.plist changes nearly nothing. In fact the only apparent effect of the operation is the location setting in the preferences that, upon running the app, has its value reset from the value I had entered.

Fabrizio Bartolomucci
  • 4,948
  • 8
  • 43
  • 75
  • same problem, i'm going into setting to unlock location tracking. Once i got the notification for authorization but she doesn't appear again – bourvill Jun 24 '14 at 13:20
  • As a matter of fact, once I set the values in the info.plist file, the Emulator correctly localizes the user. Yet, my only iOS 8 device, my iPad, presents the alert but then returns the familiar error and coordinates (0,0). – Fabrizio Bartolomucci Jul 07 '14 at 13:15
  • Apparently yes, now my apps correctly localize the user, but I totally forgot what was the fix, if any. Basically it all boils down to setting the right keys in the info.plist, and asking for the new permission soon after creating the locationManager. What happens to you in particular? – Fabrizio Bartolomucci Sep 19 '14 at 09:11
  • added answer to be able to show you an image! – Anders Sep 19 '14 at 12:31
  • Is a duplicate of http://stackoverflow.com/questions/24062509/ios-8-location-services-not-working – ErikAndren Oct 01 '14 at 06:07

3 Answers3

6

I added the two lines to my plist (see below), and furthermore i call [locationManager requestWhenInUseAuthorization]; first line in my viewDidLoad:..

Do you have any suggestions? =)

enter image description here

Anders
  • 719
  • 8
  • 22
  • Yes, you should enter a value for the key. The issue is quite vicious. I also bounced against this thing. – Fabrizio Bartolomucci Sep 19 '14 at 13:32
  • 1
    It makes no difference whether there is a value or not (just tried). The strange thing is, that: if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusAuthorized) return true, but i still don't get updates. I no longer get the error message. – Anders Sep 19 '14 at 13:38
  • The important thing is that the user gets localized. Sometimes the message does not pop up. – Fabrizio Bartolomucci Sep 19 '14 at 13:39
  • What do you mean by localized? It does not pop up because the access is already granted... Which is why i don't understand why it doesn't work :( – Anders Sep 19 '14 at 13:57
  • I mean that the location communicated by the locationsChanged callback is the one where you stay and not the gulf of Guinea - coordinate (0,0). – Fabrizio Bartolomucci Sep 19 '14 at 14:06
  • It seems that the simulator is buggy, since it would work sometimes and sometimes not.. As long as you have updated the plist. and ask for authorization, it works on the device. – Anders Oct 01 '14 at 09:37
  • Might help some with the plist editor to right click and select show Raw... This lets you see the actual key names better. – dfowler7437 Jun 24 '15 at 23:51
6

I was having the same problem. I had edited the XXXTest-Info.plist file instead of XXXInfo.plist file. Now I got it working, with little less hair on my head.

FlySoFast
  • 1,854
  • 6
  • 26
  • 47
-1

in the string the keys write YES it will look like Application requires iPhone enviroment YES

Erinson
  • 78
  • 8