HKObserverQuery is not immediately call when using Apple Watch?

I created a HKObserverQuery for HKQuantityTypeIdentifierStepCount.


If I add the count of steps walked wearing the Apple Watch, UpdateHandler of HKObserverQuery is not trigger immediately.

While the app to the active state, UpdateHandler of HKObserverQuery is only called about 2 times per hour.

Its timing is regularly. It seems the next call is just called after 30 minutes even if there is new data in the meantime.


Strange things are ...

When I changed my app to background state and to reactive, updateHandler of HKObserverQuery be called at its timing.

In the case of a number of steps that have been registered in the iPhone is called updateHandler immediately.

This issue occurs by the data of AppleWatch only.


I tried to use timer instead of HKObserverQuery, but did not get the new changed data.


Can I get latest data immediately without app to background?

or is this bug?


Please advise!

If your watch app is active, you can use a query other than an observer query to get the current steps.

I want to do on the iPhone app.

I'm sorry for not writing that.


Do you have any idea ?

The same is true on iphone, unless I am not understanding what you want.


If you want to know all the steps from the current time until the beginning of today, use a query that returns the steps immediately, rather than an observer query. It will run in the foreground when your app launches.

Thank you for your reply!


I am using the HKStatisticsCollectionQuery and HKSampleQuery to get the data.

If the app is active, HKStatisticsCollectionQuery does not return the latest Apple Watch's data.


As far as I have surveyed,

The timing at which it is possible to obtain the most up-to-date data in HKStatisticsCollectionQuery is the same as HKObserverQuery.


Its timing is these.

1. at the application is launched

2. at the app becomes active from the background state

3. after trigger of change in HKObserverQuery (about 2 times per hour only)


In other words,

It seem to Update timing of Healthkit's database has been limited to about 2 times per hour if during the iPhone app to be active (at front).


I am looking for a method that can always get the latest information that include Apple Watch's data on the iPhone app.

Were you able to find an answer? 5 years ago? lol. Im coming up to this problem right now.

HKObserverQuery is not immediately call when using Apple Watch?
 
 
Q