lucaspbordignon/rn-apple-healthkit

AppleHealthKit.setObserver listener only fires when app is in foreground?

hamxiaoz opened this issue · 5 comments

I'm testing in emulator and my phone with AppleHealthKit.setObserver. Here is what I found out:

Test 1 - it fires when app is foreground

  1. open react native app, make sure observer is setup
  2. open health app, manually add walking distance data
  3. go back to the react native app, the moment I open the app, I can see observer fired

Test 2 - it doesn't fire when app is in background

  1. open react native app, make sure observer is setup
  2. open health app, manually add walking distance data
  3. waited for couple of hours, nothing happened.

Can anyone confirm the observer works with background app?

Same issue here!

Hi @hamxiaoz and @ausaquiVS , did you manage to get the setObserver method running?
I'm trying to read out BloodGlucose data in the background, but for me it it doesn't even fire when the app is coming back to the foreground.
Appreciate any leads!

@hamxiaoz @ausaquiVS @Vollkorn01 Hey! It seems that this repository is not being actively maintained now, so I've created a new NPM package and started to maintain and add new features there

The repo is this one and I've added some additional documentation and fixed a few issues we have related to the observers in the current build for the rn-apple-healthkit

Also have worked to allow individual observers for each identifier. Would love to hear your thoughts on that and have any additional help, in case that make sense for you guys!

@Vollkorn01 Additionally, probably the BloodGlucose observer is not being triggered now because the library does not support it. Is a great option to add it, as this is a feasible feature but wasn't implemented

I've created a new issue to add support for it

@lucaspbordignon Great stuff that you create a new package! We decided to read out health data as soon as it is written into apple health through enablebackgrounddelivery. We outsourced this task, because there doesn't seem to be any react native implementation. If you're interested, maybe I can share the code when it is finished!