iOS Question IOS iLocation accuracy and kCLLocationAccuracyBestForNavigation

touchsquid

Active Member
Licensed User
Longtime User
I have both Android and IOS verions of the same App, which tracks and records yacht races. The Android veriosn is quite accurate, but the iphone version is much less so. Using Googlemaps and running the apps side by side on a road (for reference) The difference is plain. The Android verion shows a location which corresponds with my actual know position, the IOS app shows a position 10 meters or more from the known location.

Reading Apple documentation on GPS I see there are several accuracy constants the most accurate of which is

kCLLocationAccuracyBestForNavigation​

This level of accurate is available only if isAuthorizedForPreciseLocation is true.

I am using iLocation library

So, my question is, how do I enable the highest level of accuracy? It is crucial to the app.

Thanks to all who reply!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The documentation is not clear enough, however it looks like precise location is available by default and I don't think that it is actually related. However worth a try.

B4X:
Private Sub IsAuthorizedForPreciseLocation (lm As LocationManager) As Boolean
    Return lm.As(NativeObject).GetField("manager").GetField("isAuthorizedForPreciseLocation").AsBoolean
End Sub

Private Sub SetAccuracy(lm As LocationManager, accuracy As Double)
    Dim no As NativeObject = lm
    no = no.GetField("manager")
   no.SetField("desiredAccuracy", accuracy)
End Sub

Private Sub StartLocationUpdates
    If LocManager.IsAuthorized Or LocManager.AuthorizationStatus = LocManager.AUTHORIZATION_NOT_DETERMINED Then
        Log("precise location: " & IsAuthorizedForPreciseLocation(LocManager))
        If IsAuthorizedForPreciseLocation(LocManager) Then SetAccuracy(LocManager, -2) 'kCLLocationAccuracyBestForNavigation
        LocManager.Start(0)
    End If
    LocManager.StartHeading
End Sub
 
Last edited:
Upvote 0
Top