3

I am currently working on a crash issue reported by a customer. From the crash logs seems like our app is trying to send location data to backend in JSON format, and it throws Invalid number value (infinite) in JSON write because JSON does not support infinity value.

The app uses Moya library to send data, and here's the location data being sent (where location variable is of type CLLocation returned by iOS location update):

var dict =  ["latitude": location.coordinate.latitude,
                     "longitude": location.coordinate.longitude,
                     "speed": location.speed >= 0 ? location.speed : 0,
                     "altitude": location.altitude,
                     "horizontal_accuracy_estimate": location.horizontalAccuracy,
                     "vertical_accuracy_estimate": location.verticalAccuracy] as [String: Any]

So I'm guessing one of the parameters here has the value Double.infinity

However, upon checking the Apple documentation, it does not specify or even mention infinity being one of the possible values so I am confused.

I am guessing horizontalAccuracy might be Double.infinity when the location is really inaccurate? But in that case wouldn't it be better not to return it at all? Because in our app we set:

desiredAccuracy = kCLLocationAccuracyBestForNavigation
Raptor
  • 53,206
  • 45
  • 230
  • 366
Bruce
  • 2,357
  • 5
  • 29
  • 50

0 Answers0