Problem with location services iOS 8.1

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Problem with location services iOS 8.1

Post by jekyllandhyde » Wed Dec 17, 2014 5:53 am

MAC OSX: 10.10.1
Livecode: 6.7
Available device SDK's 7.1, 8.1 (Xcode version installed: 6.1)

Build is for iPhone and iPad 7.1 or later.
Location Authorization Type: when in use
Requirements and Restrictions: nothing is ticked, everything set at "n/a"

I just submitted my App to the App store and it was approved, I took my previous version and the only change was to use "exact fit" for device scaling.

The problem is that I have a piece of code that grabs GPS co-ordinates and puts them in an email and also maps them. Under IOS 7.1 this works fine. Under IOS 8.1 it does not. GPS co-ordianates end up empty. App is the same on both versions of IOS. On the iPhone 5 (iOS 8.1) if I go to Settings / Privacy / Location Services (on) / "my app name" then it is set to "Always" until I launch the App then it loses it's setting. There is no "while using" option either.

I know there have been recent changes to location services but I have no idea where to start to fix the problem?

Thanks in advance.

Adam

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: Problem with location services iOS 8.1

Post by dave.kilroy » Sun Dec 21, 2014 12:20 pm

Hi jekyllandhyde

Whilst debugging what do you get from the trackingError message? Also what are mobileLocationAuthorizationStatus() and mobileCanTrackLocation() giving you?

I haven't tried location stuff yet on iOS 8 so can't give any specific advice on this...

Good luck!

Dave
"...this is not the code you are looking for..."

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Sun Dec 21, 2014 11:22 pm

Dave,

Thanks for the response. I'm not sure how to implement the trackingErrormessage, I'm a beginner. mobileLocationAuthorizationStatus is returning "notDetermined" under IOS 8.1 and null under IOS 7.1. Everything works for IOS 7.1 but not for 8.1. If I: get mobileSensorAvailable("location") it returns true for both IOS 7.1 and 8.1.

Here's the code to get the gps coordinates into variables:

Code: Select all

put mobileSensorReading("Location",true) into tLocation
   put tLocation["latitude"] into tLat
   put tLocation["longitude"] into tLong
   put tLocation["timestamp"] into tStamp

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Mon Dec 22, 2014 6:48 am

I think I found the problem. It seems that in standalone application settings I did not select location services and gps to be required. I never needed this in previous versions of IOS but it seems to be needed in IOS 8.1.

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Mon Dec 22, 2014 7:45 am

Not sure what to do now. It seems the only way to get lat long coordinates from location services (IOS 8.1) is to require GPS and location services in standalone application settings. The problem is I get a warning in iTunes when trying to submit the App:

The app's Info.plist can't contain values for the UIRequiredDeviceCapabilities key that would prevent this app from opening on any iOS device

I never had to select these values before, I'd rather leave them unselected but then it won't return coordinates. Is this a bug? I'm caught in a bit of a no win situation.

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Problem with location services iOS 8.1

Post by Dixie » Mon Dec 22, 2014 8:24 am

Are you starting to 'listen' for GPS with :-

Code: Select all

      /* determine the location of the mobile device */
      mobileStartTrackingSensor "location", true
before you try to determine lat/lng responses ?

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Tue Dec 23, 2014 5:51 am

Yes, I list below what code I'm using, the App's been out a year and a half and no problems till IOS 8.1:

Code: Select all

on opencard
mobileStartTrackingSensor location, false
end opencard

on closecard
   if environment() = "mobile" then
      mobileStopTrackingSensor location
      end if
end closecard

--And the script on the button on the actual card
on mouseUp
   put mobileLocationAuthorizationStatus() into tStatus
   if tStatus is "denied" then
      answer "Safe Boating cannot access your location.  Please Enable Location Services in Settings/Privacy/Location Services for this App."
   end if
   put mobileSensorReading("Location",true) into tLocation
   put tLocation["latitude"] into tLat
   put tLocation["longitude"] into tLong
   put tLocation["timestamp"] into tStamp
   --then we convert the time in seconds to date and time
   convert tStamp to short date and long time
--etc, etc

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: Problem with location services iOS 8.1

Post by ChrisMukrow » Tue Dec 23, 2014 11:28 pm

I know that there are some new values in the .plist for location services in iOS8+. Maybe these aren't implemented yet? If so you could add these values yourself in the .plist file.

The new values are:
NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription

Stackoverflow thread (native code NOT Livecode):
http://stackoverflow.com/questions/2406 ... g-in-ios-8

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Wed Dec 24, 2014 7:37 am

Chris,

Thanks for the info it led me to this article: http://nevan.net/2014/09/core-location- ... -in-ios-8/

From the writeup:
Location Manager fails to start in iOS 8

"In iOS 8, this code doesn’t just fail, it fails silently. You will get no error or warning, you won’t ever get a location update and you won’t understand why. Your app will never even ask for permission to use location. I’m experienced with Core Location and it took me 30 minutes to figure out the new behavior. Baby devs are going to be even more frustrated by this change."

it goes on to say:

So the first thing you need to do is to add one or both of the following keys to your Info.plist file: (code is native - not livecode)

NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
Both of these keys take a string which is a description of why you need location services. You can enter a string like “Location is required to find out where you are” which, as in iOS 7, can be localized in the InfoPlist.strings file.

Next you need to request authorization for the corresponding location method, WhenInUse or Background. Use one of these calls:

[self.locationManager requestWhenInUseAuthorization]
[self.locationManager requestAlwaysAuthorization]

and...

There are two kinds of authorization that you can request, WhenInUse and Always. WhenInUse allow the app to get location updates only when the app is in the foreground. Always authorization allows the app to receive location updates both when the app is in the foreground and in the background (suspended or terminated). If you want to use any background location updates, you need Always authorization. An app can include plist keys for either one or both authorization types. If an app needs foreground location for it’s main functionality, but has some secondary functionality that needs background location add both keys. If the app needs background functionality as a main requirement, only all Always.

In Livecode 6.7 the switch between when in use and always in use is a toggle, it does not allow the functionality of both, also there is no text field. My guess is the Plist file is not being generated correctly by livecode which is causing my strange behaviour with the code failing silently and not giving me gps co-ordinates in Livecode 6.7.

I could be wrong about all of this because most of it is beyond my newbie understanding.

Not sure what to do next. I might try a later version of livecode to see if this got fixed.

Adam

ChrisMukrow
Posts: 73
Joined: Mon Nov 12, 2012 4:13 pm

Re: Problem with location services iOS 8.1

Post by ChrisMukrow » Wed Dec 24, 2014 1:13 pm

Hi Adam,

What you could do is add a bug report on this site: http://quality.runrev.com/ and hopefully it will get fixed in the next version.

Chris

ludo
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 72
Joined: Mon Dec 03, 2007 6:10 pm

Re: Problem with location services iOS 8.1

Post by ludo » Wed Dec 31, 2014 2:46 pm

Same here with Livecode 6.6.5

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Problem with location services iOS 8.1

Post by Simon » Wed Dec 31, 2014 9:25 pm

Hi Adam,
Thanks for posting Bug 14290
http://quality.runrev.com/show_bug.cgi?id=14290

Will be following it.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

jekyllandhyde
Posts: 92
Joined: Thu Feb 14, 2013 7:17 pm

Re: Problem with location services iOS 8.1

Post by jekyllandhyde » Wed Mar 11, 2015 7:03 am

I can confirm that Livecode has now fixed this bug as per release 6.7.2 RC 2

Post Reply