Saturday, December 16, 2023
HomeiOS Developmentios - The best way to get the correct distance of sufferers...

ios – The best way to get the correct distance of sufferers strolling in home


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)))"
        }
    }



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments