Post

Replies

Boosts

Views

Activity

Reply to WatchOS HealthKit HKObserverQuery crashes in background
Hello Ziqiao, thanks a lot for getting back to me and for answering all my questions from my previous reply. In the meantime I also created a bug report via the Apple Feedback app and was in contact with Apple that way. After some improvement suggestions of my code, which unfortunately didn't solve the issue, they suggested to create a post here in the developer forum. So unfortunately after many tries and many ways to reach out to Apple to get this issue fixed, I still don't have a solution and the Watch app is still crashing in the background. I have attached the Swift file with the latest version of the coding for the Watch app, which includes all the suggestions I have received so far but still does not work. Could you please take a look at it again and provide me with a fixed version of this code which does not crash any more? Thanks a lot. HealthKitManager.txt
Jun ’25
Reply to WatchOS HealthKit HKObserverQuery crashes in background
Hello Ziqiao, thanks for the information. But you didn't answer my questions from the previous comment. Therefore could you please answer these questions? Is there any sample code / project from apple about how to implement background HealthKit queries on WatchOS? How many updates per hour can a WatchOS app receive in the background if there is no complication on the active watch face? If I have observer queries registered for 4 different data types, each trigger of these observer queries would count as one separate wake up if they don't occur at the same time or directly after each other within the time allowance of the first one, correct? Is it better / recommended to read HealthKit data in the background on iOS instead of WatchOS? On iOS I discovered the problem that I cannot read heart rate data in the background if the iPhone is locked. Is there a way to read heart rate data in the background on iOS if the iPhone is locked? Is there a list of data types from HealthKit which ones can be read in the background if the iPhone is locked and which ones cannot? Thanks a lot! Tobias
Apr ’25
Reply to WatchOS HealthKit HKObserverQuery crashes in background
Hi Ziqiao, thanks for the reply. I have already tried disabling the data transfer to the iPhone via wcsession, but the same error still occurs. Is there any sample code / project from apple about how to implement this? One other question came to my mind: You said that my app can receive 4 updates per hour as long as it has a complication on the active watch face. I don't have a complication for the app. Does this mean that the app can only receive up to 1 update per hour from the HKObserverQuery? What would happen if I also want to get updates from other data types, not just heart rate. For example in addition also step count, calories, blood oxygen. If I would register an HKObserverQuery for each of these 4 data types with a frequency of hourly. If all 4 HKObserverQueries "wake up" every hour, would that already be 4 background updates per hour? Which would be too much already without a complication. Thanks & best regards, Tobias
Apr ’25