Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Location services don't work in iOS 8, now apparently fixed in daily build
Started by corona273 Sep 19 2014 08:00 AM

18 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

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.

 



[TOPIC: post.html]
#2

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

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.


[TOPIC: post.html]
#3

Appoet

[GLOBAL: userInfoPane.html]
Appoet
  • Observer

  • 28 posts
  • Enterprise

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.



[TOPIC: post.html]
#4

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

Are you getting prompted for permission to use Location services?



[TOPIC: post.html]
#5

Appoet

[GLOBAL: userInfoPane.html]
Appoet
  • Observer

  • 28 posts
  • Enterprise

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



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

Any messages in your device's console log?

What version of Corona SDK are you using?



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

And your build.settings while we are asking...



[TOPIC: post.html]
#8

Appoet

[GLOBAL: userInfoPane.html]
Appoet
  • Observer

  • 28 posts
  • Enterprise

Corona Version: 2014.2439 (2014.9.19)

 

Build.settings:

 

 UIBackgroundModes = {
            "location",
            },


[TOPIC: post.html]
#9

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

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.



[TOPIC: post.html]
#10

Appoet

[GLOBAL: userInfoPane.html]
Appoet
  • Observer

  • 28 posts
  • Enterprise

Where does that need to be added?



[TOPIC: post.html]
#11

corona273

[GLOBAL: userInfoPane.html]
corona273
  • Contributor

  • 482 posts
  • Enterprise

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.



[TOPIC: post.html]
#12

Dave Haynes

[GLOBAL: userInfoPane.html]
Dave Haynes
  • Contributor

  • 233 posts
  • Corona SDK

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."



[TOPIC: post.html]
#13

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

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



[TOPIC: post.html]
#14

Dave Haynes

[GLOBAL: userInfoPane.html]
Dave Haynes
  • Contributor

  • 233 posts
  • Corona SDK

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.



[TOPIC: post.html]
#15

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

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



[TOPIC: post.html]
#16

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

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



[TOPIC: post.html]
#17

Dev-Ze.rocks

[GLOBAL: userInfoPane.html]
Dev-Ze.rocks
  • Contributor

  • 213 posts
  • Corona SDK

Does this plist parameter (NSLocationWhenInUseUsageDescription) support localization?

How can I insert my notification text in different languages?

 

Cheers,

Felix

 

Edit: Nevermind, I think I found the solution, needs to be done via the infoPlist.string files, right?



[TOPIC: post.html]
#18

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,068 posts
  • Enterprise

[TOPIC: post.html]
#19

Dev-Ze.rocks

[GLOBAL: userInfoPane.html]
Dev-Ze.rocks
  • Contributor

  • 213 posts
  • Corona SDK

Thank you Rob!

It would be a good idea to write somewhere in this guide that the you can add any localizeable plist entry to the InfoPlist.strings - files, not only the CFBundleDisplayName and the CFBundleName.

 

Cheers,

Felix




[topic_controls]
[/topic_controls]