Questions tagged [hkobserverquery]
20 questions
66
votes
1 answer
iOS : Use of HKObserverQuery's background update completionHandler
HKObserverQuery has the following method that supports receiving updates in the background:
- initWithSampleType:predicate:updateHandler:
The updateHandler has a completionHandler which has the following documentation:
This block is passed to the…

ospr
- 1,650
- 2
- 17
- 21
5
votes
2 answers
HKObserverQuery randomly called twice in a row
I have an issue I'm trying to solve, I've setup an HKObserveryQuery, which works great and gathers new data for me.
The issue however is that sometimes when I go back to the Health app and delete an item after I've manually added it to the Health…

klcjr89
- 5,862
- 10
- 58
- 91
4
votes
1 answer
enableBackgroundDelivery Health-kit iOS15 not working correctly
I am working on the health kit. Before iOS15 below code is working correctly I am getting vitals on an hourly basis but in this latest version, I am not getting any vitals event per hour.
I am facing an issue in iOS15 not getting any event in an…

Mayank Patel
- 3,868
- 10
- 36
- 59
4
votes
1 answer
Propagating HealthKit Delete to back end
Hope this question doesn't sound too silly, but I haven't been able to find a solution yet. I'm currently writing an app using Xamarin that integrates with HealthKit. Data stored in HK is periodically synced to a server. This is done through an…

jmf
- 41
- 2
3
votes
1 answer
HKObserverQueryCompletionHandler timeout?
I use HKObserverQuery and background delivery in my iOS application. In the updateHandler of HKObserverQuery I execute a query (HKAnchoredObjectQuery) and send results to the remote server via https. But on a slow connection (EDGE for example) and…

sergeyne
- 1,268
- 12
- 18
2
votes
1 answer
Call something when step count is updated
Right now, I'm trying to set up my app so that a function is called when the user updates their step count. So far, I have the following code:
let steps: HKObjectType = HKObjectType.quantityType(forIdentifier: .stepCount)!
if…

LFHS
- 295
- 1
- 2
- 15
2
votes
2 answers
HKObserverQuery Fails with Authorization Not Determined
When trying to set an observer query for Healthkit, for a lot of users I'm getting an error of Authorization not Determined.
After researching for a bit I saw that an error like that should only happen when trying to write (share) data to…

Gadi Gomez
- 23
- 1
- 3
1
vote
1 answer
How do I use Healthkit observer queries with background delivery without prompting non-HK users for permissions?
Users of this app can choose whether they would like to use Healthkit features (they are not necessary for the app to work). I would like to set up an observer query to send data to the server in the background.
According to Apple's documentation at…

mmaxx
- 13
- 2
1
vote
1 answer
Healthkit queries dont work when the app is in background
I need to observe the heart rate data in Healthkit and then send a notification to the user accordingly. The code is working fine, but every time I have to bring the app to foreground to be able to get notifications. I need that working…

Atakan Poyraz
- 11
- 2
1
vote
1 answer
Healthkit: Set up 'enableBackgroundDelivery' but iOS is not at all waking up the app when there is new health data for the user on some devices
I'm working with HealthKit SDK on my app(it's related to Health). I set up 'enableBackgroundDelivery', expecting iOS to wake up my app whenever there is a new health data for the user so that I can start querying user's health data. iOS is waking up…

Ashok
- 5,585
- 5
- 52
- 80
1
vote
0 answers
Able to read HealthKit data through HKObserverQuery even after I disabled the permission in the Health App. Is this a bug?
I am working on an app that has an HKObserverQuery that starts immediately when the view is loaded. That HKObserverQuery calls to a function that executes an HKStatisticsQuery that can retrieve the sum of all the step count for today.
When I started…

Rushit Rakhasiya
- 21
- 2
- 8
1
vote
1 answer
HealthKit does not launch app when new data is added and hkObserverQuery is set up
I am trying to have HealthKit launch my app whenever there is new data available. So I tried to use HKObserverQuery with background delivery following this example that I find on GitHub.
I have the background modes capability enabled for my project…

lzt
- 98
- 6
1
vote
0 answers
HKObserver updateHandler stop execution
I need to upload steps on server even when app is in background. I have added HKObserverQuery with enableBackgroundDeliveryForType for HKQuantityTypeIdentifierStepCount.
When update notification receive from observer, it will query for one day…

nadim
- 776
- 1
- 12
- 26
1
vote
1 answer
HKObserverQuery only runs when the application is reopened
So I've been following the instructions in this answer...
Healthkit background delivery when app is not running
The code runs fine and works whilst the application is open and says that background delivery is successful, however when I test the…

user3599895
- 275
- 1
- 2
- 13
1
vote
0 answers
Does HKObserverQuery can receive notification when the application not running(Killed)?
My requirement is to register for any one of the Health data like steps, weight, heart rate, etc., for background delivery using enableBackgroundDeliveryForType: method. And then create a Observer query for the same Health data to check.
In this…

Bhanu Prakash
- 1,493
- 8
- 20