Lena Stepanova
06/11/2021, 1:35 PMsingle<TrackingKtorApi> {
TrackingApi(
getWith("TrackingApi")
)
}
It's injected in the GeofencingModel like this
private val trackingApi: TrackingKtorApi by inject()
And the place where the exception happens is when from ios app geofencingModel.saveGeofencingData(lat, long) ist called
suspend fun saveGeofencingData(latitude: Double,
longitude: Double): String? {
return try {
val data = TrackingData(
lat = latitude,
long = longitude)
insertOrReplaceTrackingInDb(data)
val saved = getAllTrackings()
if (saved.isNotEmpty()){
sendGeofencingData(saved)
}
null
} catch (e: Exception) {
e.printStackTrace()
"Couldn't send tracking data"
}
}
suspend fun sendGeofencingData(data: List<TrackingData>) {
try {
trackingApi.postTrackingData(data, getFleetAccessToken())
removeAllTrackings()
} catch (e: Exception) {
e.printStackTrace()
}
}