Location services don't work in iOS 8, now apparently fixed in daily build

From:

https://developer.coronalabs.com/corona-daily-builds/summary

  • iOS: Request location services permissions when using location services on iOS 8. NSLocationWhenInUseUsageDescription will need to be added to the plist or the permission won’t be requested correctly. Casenum: 35679

It’s good to see this (apparently) fixed. I was going a bit nuts yesterday wondering why this wasn’t working, and (sigh) blaming my own code.

I’m happy to say this daily build fixes the iOS 8 location problem. With the previous one you’d get this error:

Sep 19 10:02:05 iPhone locationd[63] <Notice>: ERROR: CoronaAppName is depending on legacy on-demand authorization, which is not supported for new apps

Now it works properly. In case it’s not obvious, BTW, NSLocationWhenInUseUsageDescription is a string that’s displayed to the user during the modal dialog box for location authorization.

I’ve been trying to get this to work on Infused with the latest daily build but it never starts the gps. Are you guys sure this was fixed?

Thanks.

Are you getting prompted for permission to use Location services?

No, I’m not getting anything at all. Thanks.

Any messages in your device’s console log?

What version of Corona SDK are you using?

And your build.settings while we are asking…

Corona Version: 2014.2439 (2014.9.19)

Build.settings:

 UIBackgroundModes = {

            “location”,

            },

You need to add:

      NSLocationWhenInUseUsageDescription = “Some message to show people that you’re asking for location services”,

since you’re going to run in the background, you should also alert the user that you will be using the GPS when the app is in the background.

Where does that need to be added?

If you reread this topic, you’ll see that Rob mentioned your build.settings file, which is where that needs to go. It should be under settings/iphone/plist.

It doesn’t look like NSLocationUsageDescription is used, BTW, just NSLocationWhenInUseUsageDescription.

This really ought to be added to the documentation here:

http://docs.coronalabs.com/api/library/native/newMapView.html

I was confused by the post here:

https://coronalabs.com/blog/2014/09/24/ios-8-and-corona-sdk/

because it says this:

Requires new plist parameter (“NSLocationWhenInUseUsageDescription”) in build.settings when building with the iOS 8 SDK. There is no issue when building with the public release build (2393a) running on either an iOS 7.x or iOS 8 device; on daily builds, there is similarly no issue as long as you build against iOS SDK “7.1” (not “8.0 Beta”).

Since I’m choosing 7.1 from the drop down, I assumed that meant all was well for me, but it wasn’t…

Adding the NSLocationWhenInUseUsageDescription to the plist in build.settings is apparently required for iOS 8 devices, even if you’re choosing “7.1” from the iOS SDK drop down in the Corona Build window. So really, it might as well just be considered required for everyone from now on, which is also why it really should be added to the Gotchas in that documentation, along with the android settings.

Also, I didn’t know what that usage text was for, or what it should look like. In the end, I figured it out. It’s what shows up when you go into Settings > Privacy > Location Services > Your App.  At the bottom of that screen, it says, “App explanation:”, then shows your explanation.

An example is the Camera app. Its explanation is, “Photos and videos will be tagged with the location where they are taken.”

Help me understand the problem better.

Using 2393a the current public build, I built the GPS sample app.  The public build only uses iOS 7.1.  I installed it on my iPhone 6 running iOS 8.1.

I got a dialog box asking me permission to use the GPS.  The message did contain the language about using the GPS all the time, which the above key is designed to address.  Selecting Yes, it grabbed my GPS data as expected.

iOS 7 asked for permission to use the GPS as well.  iOS 8 devices absent of the key above will give you a default message. 

Just to clarify something I said above:  Corona SDK does not support using the GPS in the background.

Rob

I looked over the GPS sample again and compared to what we have.

We’re using the mapview’s getUserLocation() method, not the location runtime event that’s used in the GPS Sample. Maybe that has something to do it with it?

Before adding the NSLocationWhenInUseUsageDescription, we tested across 2 different iPads and 2 different iPhones in different parts of the world.  The 7.1 devices had no problems. The 8.1 devices never asked us for permission, and strangely, in Settings > Privacy > Location Services, there was no option to use Location Services while the app is running for our app. There was an Allow or Deny, and Allow had no effect.

We upgraded one of the iPads running 7.1 to 8.1 to see what would happen. It worked previously, then it stopped working (no longer asking for permission to use location services) after the upgrade.

This was on Daily Build 2014.2478. However, adding that one thing – NSLocationWhenInUseUsageDescription – made it work everywhere.

We will need a bug report that shows your issue.  Please make sure to provide a build.settings and config.lua.

Please post the bug # back here that you get the email.

Rob

Please note Corona SDK does not support using the GPS while in the background (or any background mode for that part). 

I’m happy to say this daily build fixes the iOS 8 location problem. With the previous one you’d get this error:

Sep 19 10:02:05 iPhone locationd[63] <Notice>: ERROR: CoronaAppName is depending on legacy on-demand authorization, which is not supported for new apps

Now it works properly. In case it’s not obvious, BTW, NSLocationWhenInUseUsageDescription is a string that’s displayed to the user during the modal dialog box for location authorization.

I’ve been trying to get this to work on Infused with the latest daily build but it never starts the gps. Are you guys sure this was fixed?

Thanks.

Are you getting prompted for permission to use Location services?

No, I’m not getting anything at all. Thanks.