Reputation: 1159
I have looked through so much Apple documentation and SO questions but still can't figure out why or even if this should work.
I have a long running HKObserverQuery
, I set this up in my AppDelegate
and I have all the required permissions, entitlements and info.plist stuff set so it works fine from that perspective.
On the simulator I can run my app and background it, add some data to the HK database manually and I see my debugger write out that the observer query handler was hit.
The problem is that the observer handler creates an HKAnchoredObjectQuery
but the anchored query handler is never fired while the app is in the background. When I bring the app to the foreground, the observer and anchored query run properly and both handlers fire and write to my debug log.
My question is, should the anchored query handler respond while the app is in the background?
I'm killing myself because I am supposed to be getting the user's step data and sending it to a server, but right now I can only get that data if the user activates the app.
Upvotes: 0
Views: 491
Reputation: 411
Call the completion handler on the observer query after you're done reading/processing data from the anchored object query.
Upvotes: 0