Reputation: 11
I need to send HealthKit data to a server periodically. I'm using React Native and rn-apple-healthkit
. I tried react-native-background-task
, but it won't work while the application is closed (not background mode). I read in Apple developer docs that it happens by design.
I found some solutions online such as geolocation services, running a socket and "playing" silent sounds, piggybacking on push notifications but they all seem like workarounds.
Is there a good way to do this in 2019?
Upvotes: 0
Views: 1591
Reputation: 160
Using silent notifications is the correct way of achieving this. However it wont work when the phone is locked:
For security, the HealthKit store is encrypted when the device is locked, and the HealthKit store can only be accessed by an authorized app. As a result, you may not be able to read data from the store when your app is launched in the background; however, apps can still write data to the store, even when the phone is locked.
Taken from https://developer.apple.com/documentation/healthkit/protecting_user_privacy
Upvotes: 1