GPS in iOS 7.1.2

Hi,

I’m using Antonio’s code to use GPS. It’s working great on my iOS 8.x devices, and it’s also working fine on my iPhone 4S that is still running iOS 7.1.2.

For some bizarre reason, it’s not working on the iPhone 4 I’ve got, that’s also running iOS 7.1.2.

Even more strange, if I go to Settings and Privacy in the iPhone 4S, the app I’m working is listed and shown as allowed to access GPS. On the iPhone 4, there is no entry for the app, so it’s not even showing as disabled.

Any ideas? Or is it really to do with the iPhone 4? I don’t have a second one to test against.

Got it.
In the requestWhenInUseAuthorization method of the CLLocationManager class add:

else dim c as CoreLocation.CLLocation c=location

You will call this method for asking the Authorization on iOS8, but on iOS7 the Authorization is asked as you call the location.

Since I have no more iOS7 device, I can test only on the simulator.
So, can you test this fix on the iPhone4? If it works I will update the library.

The curse of a work iPhone that’s several years old and no longer gets updates :wink:

Just building now.

Nope. No luck. Still works on the 4S running 7.1.2, but not the 4 running the same OS.

That’s really odd
If you run the sample app what’s the Authorization status?

I know. If it didn’t work on both the 4 and 4S running the same version, I’d just put it down to 7.1.2, but…

Authorization Status: (0) NotDetermined
Location Services: Enabled
Deferred…: Not Available
Significant…: Available
Heading: Available
RangingNot: Available

Hmm. Stopped working on the 4S as well now. Not quite so strange after all.

I don’t know if it helps, but Jason’s version works on 7.1.2.

I’ve hacked my app at the moment to use your version for 8.x and his for 7.x.

Jason calls the current location directly, the update, I told you to implement, should do the same (otherwise with the origina code it will do nothing…)
This is only for the NotDetermined state.

On IOS7 if it’s not determined you have use it to force the user reply.

I don’t know why your change doesn’t work, but it doesn’t. shrug

Just to make sure, the final code for CoreLocation.CLLocationManager.requestWhenInUseAuthorization should look like this:

if iosLib.respondToSelector(handle,"requestWhenInUseAuthorization") then Declare sub requestWhenInUseAuthorization_ lib CoreLocationLib selector "requestWhenInUseAuthorization"(o as Ptr) requestWhenInUseAuthorization_(handle) else dim c as CoreLocation.CLLocation c=location end if

If so, not sure what to try next.

try this:

  if iosLib.respondToSelector(handle,"requestWhenInUseAuthorization") then
    Declare sub requestWhenInUseAuthorization_ lib CoreLocationLib selector "requestWhenInUseAuthorization"(o as Ptr)
    requestWhenInUseAuthorization_(handle)
  else
    startUpdatingLocation
  end if

Bingo! That’s done it. Brilliant! Thanks a million.

Now working in both iOS7.1.2 and iOS8