I have released a golf app based on GPS a year ago. To make the best use of it a high horizontal accuracy is needed. Everything was working fine since the release of the app (iOS 10 was the latest operating system version at that time). Now, customers are reporting bad accuracy with iOS12 mainly in combination with iPhone X derivatives.
I was able to reconstruct the issue on my development devices. On iPhone X horizontal accuracy of <5m is not achievable anymore. Was no issue before. On iPhone 6s this level of accuracy is achieved in rare cases. On both devices, iOS 12.2 was installed.
Here is the related code in my app:
Variable definition in the class:
var locationManager: CLLocationManager = CLLocationManager()
In View Did Load I have put:
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.requestAlwaysAuthorization()
locationManager.startUpdatingLocation()
Then der is the following function to determine the location (latestLocation
) which is processed in the code (not shown here):
func locationManager(_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation])
{
let latestLocation: CLLocation = locations[locations.count - 1]
horizontalAccuracy.text = String(format: "%.1f",latestLocation.horizontalAccuracy)
if latestLocation.horizontalAccuracy <= 5.1 {
horizontalDistance.backgroundColor = UIColor.green
} else if latestLocation.horizontalAccuracy <= 10.1 {
horizontalDistance.backgroundColor = UIColor.yellow
} else {
horizontalDistance.backgroundColor = UIColor.red
}
// remark: this sets the background color of a label according to
achieved horizontal accuracy. Since iOS12 the maximum achieved level of accuracy with an iPhone X is medium (yellow background color).
/*
Some code processing location data
*/
}
In general, the code is executed as expected but on the basis of low accuracy data. Is there something is missed for iOS 12 or is there a way to enforce a higher accuracy? Thanks for your help!