If I’m utilizing the CoreMotion framework and CMPedometer class to get the space of the person strolling however it’s not the correct distance of the person walks even after I use the well being package to get the distanceWalkingRunning question then additionally it is not obtained the correct distance of person stroll. how can I get the correct distance of the person’s stroll?
personal func startTrackingSteps() {
pedometer.startUpdates(from: Date(), withHandler: { (pedometerData, error) in
if let pedData = pedometerData{
print("pedData:(pedometerData)")
self.setPedometerData(pedData: pedData)
} else {
self.numberOfSteps = nil
}
})
}
personal func setPedometerData(pedData: CMPedometerData){
self.numberOfSteps = Int(truncating: pedData.numberOfSteps)
if let distancee = pedData.distance{
let averageStepLength = 0.67 // Common step size in meters (regulate as wanted)
let distance = Double(self.numberOfSteps) * averageStepLength
self.distance = Double(truncating: distancee)
}
DispatchQueue.most important.async {
self.stepsLbl.textual content = "Steps (self.numberOfSteps)"
self.distanceLbl.textual content = "Distance: (self.getDistanceString(distance: self.distance))"
self.TimeLbl.textual content = "Time: (self.secondsToHoursMinutesSeconds(Date().secondsInBetweenDate(self.startDate)))"
}
}