HKObserverQuery BackgroundDelivery not executed

Hi, I'm having the same issue described in https://aninterestingwebsite.com/forums/thread/690974?page=2.

When connected to Xcode or when the app is in the foreground, HKObserverQuery fires correctly and my app processes step updates. But once disconnected from Xcode, background delivery stops completely and the observer callback is never called.

My setup:

  • com.apple.developer.healthkit.background-delivery entitlement is present and in the provisioning profile
  • enableBackgroundDelivery(for: .stepCount, frequency: .immediate) returns success = true
  • HKObserverQuery is registered on every launch including background launches
  • I also have CMPedometer.startEventUpdates running as a supplemental trigger
  • Background Modes includes "Background fetch" and "Background processing"

Device: iPhone, iOS 17.4+
App type: App uses Screen Time / Family Controls (ManagedSettings) to block apps until a step goal is met

Has anyone found a reliable fix?

Any feedback from Apple engineers would be appreciated.

The configuration you described looks good to me. So ... is it that the HealthKit background delivery doesn't happen at all, or is it that the delivery happens sometime but not stably?

When seeing HKObserverQuery + enableBackgroundDelivery not working, I typically suggest the following check:

  • Is the completion handler (HKObserverQueryCompletionHandler) in the updateHandler of the HKObserverQuery called in all code paths and in a timely way, as mentioned here?

  • Is the app force quitted when testing, as mentioned here?

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

HKObserverQuery BackgroundDelivery not executed
 
 
Q