App state | Behaviour |
---|---|
Foreground | Apple HealthKit delivers any buffered and new changes immediately. |
Background | Hourly batch delivery of changes, subject to operating system throttling. |
Add Vital SDKs as dependencies
Integrate with Vital Mobile SDK Authentication
Configure Health SDK and ask user for read permissions
VitalResource
s which you have asked permissions from your user for. If you
did not ask for permissions, data sync would not occur.Configure Background Delivery
Info.plist
file — these entries should be
configured:
Key | Value |
---|---|
Privacy - Health Share Usage Description ( NSHealthShareUsageDescription ) | An explanation of your usage of the user’s HealthKit data. |
Permitted background task scheduler identifiers ( BGTaskSchedulerPermittedIdentifiers ) | Include io.tryvital.VitalHealthKit.ProcessingTask in the array, alongside any other BGTask identifiers of yours. |
Key | Value |
---|---|
Privacy - Health Update Usage Description ( NSHealthUpdateUsageDescription ) | An explanation of what user health data your app is writing to Apple HealthKit. |
syncData()
manually at all. Once you have asked the user for permission on
resources, sync would automatically starts every app launch, as well as whenever your app is woken up by Apple HealthKit to
respond to newly available data.
HealthKit wakes your app whenever a process saves or deletes samples of the specified type. The system wakes your app at most once per time period defined by the specified frequency. Some sample types have a maximum frequency ofThis means that although we have background delivery’s frequency set toHKUpdateFrequency.hourly
. The system enforces this frequency transparently. For example, on iOS,stepCount
samples have an hourly maximum frequency.
.hourly
, we cannot guarantee hourly syncing on the dot.