Hi Ziqiao,
Sorry for the slow response, I've been trying to do some more testing before responding...
I think I was getting confused in some instances between WKApplicationDelegateAdaptor and WKExtensionDelegateAdaptor. This is a modern single target app so yes I should be using the former. And thank you on the tech note, really useful for clarity on the confusing!
I am now finding that with the @WKApplicationDelegateAdaptor route I can implement the func handle(_ backgroundTasks: Set<WKRefreshBackgroundTask>) {} method and there do work and schedule the next update. With a widget/complication on the watch face I get update calls variably between every 15-90 minutes despite requesting an update every 15 minutes. This is running the latest WatchOS 26.3, I appreciate there are lots of constraints on this which are hard to debug, but despite that I would have expected slightly more updates to get closer to the "4 per hour" target. Removing the complication from the watch face seems to take the update number to never, again I though the occasional update might have been called.
The crashes continue to roll in on my iPhone in the Analytics data section for this test app. Every few minutes I still get a CSLHandleBackgroundHealthKitQueryAction watchdog transgression despite having removed the HealthKit background observer code and the .enableBackgroundDelivery(for: HKQuantityType(.heartRate),frequency: .immediate) entry. I presume there's no way to .disableBackgroundDelivery()? Is there anything else you need me to do here or try relating to FB22115840? To clarify my previous statement about being able to "use the HealthKit background observer query to receive heart rate data once per hour with or without a complication on the watch face", I more mean that the crashes continue to occur regardless of a complication on the watch face or not.
The feedback did receive a reply mentioning DispatchQueue.main.async use and maybe an issue with completing a task too early? It was a little confusing, but in any case I’d tested without using the DispatchQueue.main.async so there’s still a problem here.
Many thanks
Topic:
App & System Services
SubTopic:
Health & Fitness
Tags: