Pedometer updates frequency

I am currently developing app that counts the Steps, and for that I am using the pedometer. I am not sure of how frequent pedometer provides updates, in my case it provides update around 3 second. There is nothing mentioned about frequency of Data in Official documentation of Apple or Any ways to set the Frequency.

Application is in Both iOS and WatchOS plateform

To achieve data i have tried following things:

  • With startUpdates(from: Date)
pedometer.startUpdates(from: Date()) { [weak self] pedometerData, error in
    guard let data = pedometerData, error == nil else { return }
    DispatchQueue.main.async {
        self?.stepCount = data.numberOfSteps.intValue
    }
}
  • With queryPedometerData()
timer = Timer.scheduledTimer(withTimeInterval: 1.0, repeats: true) { [weak self] _ in
    self?.fetchPedometerData()
}

private func fetchPedometerData() {
    pedometer.queryPedometerData(from: Date().addingTimeInterval(-1), to: Date()) { [weak self] pedometerData, error in
        guard let data = pedometerData, error == nil else { return }
        DispatchQueue.main.async {
            self?.stepCount = data.numberOfSteps.intValue
        }
    }
}

I have done this both implementation but Not getting desired results.

I want data every second, Could it be possible ? Any help or leads would really helpful

Thank You :)

Replies

@jay_shah01 I'm looking for a same subject with you. As far as I've found about this there is (probably) no way to manipulate an interval or a frequency of updating pedometer data. So I'll find out a detour of not using interval manipulation of queryPedometer but I'll follow it up if someone knocks the door of this article with having an idea for it. Hope you have a desired result for it as soon as possible.