matinzd / react-native-health-connect

React native library for health connect (Android only)
http://matinzd.github.io/react-native-health-connect
MIT License
221 stars 43 forks source link

Background Delivery #83

Open mohamadfala opened 6 months ago

mohamadfala commented 6 months ago

I would like to implement the ability to receive data from the health connect integration in the background without using background tasks with periodic updates. Is there any way to listen to an even in the background that will fire a synchronization method in my application and send new records to the server?

I was able to accomplish this in React Native Healthkit using NativeEmitter.

matinzd commented 5 months ago

You can check the proof of concept of this in this tree:

https://github.com/matinzd/react-native-health-connect/tree/headless_poc

lsandini commented 12 hours ago

https://developer.android.com/health-and-fitness/guides/health-connect/develop/read-data

This page last updated 2024-09-30 UTC and states: "Health Connect allows apps to read data from the datastore when the app is in the foreground and background"

And it works ! I tested setting up a background-fetch that queries Health Connect for step counts in the background, and also triggering the task in the background using a silent push notification from my backend. Steps are returned as expected.