Titanium module that reads different types of quantity data from HealthKit.
- Build this project or download the module from the
dist
directory. - Require the module.
- Add the
com.apple.developer.healthkit
entitlement to tiapp.xml (see the tiapp.xml in the example project). - Add the
NSHealthShareUsageDescription
key to tiapp.xml (see the tiapp.xml in the example project). - Call
isHealthDataAvailable
to see if HealthKit is available on the device. - Call
fetchData
to get the data you need.
Checks if HealthKit is available on the device. For example iPads don't have HealthKit. Returns a boolean.
Returns an array of time units you can use in the fetchData
function.
Returns an array of quantityTypeIdentifiers you can use in the fetchData
function.
Fetches the requested quantity data from HealthKit and calls the callback with the results.
- String
timeUnit
- SeegetTimeUnits()
for valid values. - String
quantityTypeIdentifier
- SeegetQuantityTypeIdentifiers()
for valid values. - Date
startDate
- The start date. - Date
endDate
- The end date. - Function
onSuccess
- Will be called with the result. The result is an array of key (ISO8601 date string) value (number) pairs. - Optional Function
onError
- Will be called in case of an error.
Clone this project. Go inside the ios directory and do:
ti build -p ios --build-only
This project is licensed under the GNU GPLv3 License - see the LICENSE file for details.