Namespace: HealthKit
Functions
authorize
▸ authorize(shareTypes
, readTypes
): Promise
<boolean
>
Sets up health tracking and returns status
Parameters
Name | Type | Description |
---|---|---|
shareTypes | HealthKitDataType [] | e.g. [HealthKitDataType.Fiber] |
readTypes | HealthKitDataType [] | e.g. [HealthKitDataType.Fiber] |
Returns
Promise
<boolean
>
Returns status if no errors occurred.
Defined in
deleteRecord
▸ deleteRecord(options
): Promise
<number
>
Delete record from Health API.
Must provide uuid of the record or startDate and endDate of records you wish to delete.
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate? | number | Date | Unix timestamp or Date for record end date. |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.startDate? | number | Date | Unix timestamp or Date for record start date. |
options.uuid? | string | Unique healthKit record id. |
Returns
Promise
<number
>
The number of deleted records.
Defined in
api/healthKit/deleteRecord.ts:21
getAbsoluteTotalForToday
▸ getAbsoluteTotalForToday(options
): Promise
<number
>
Gets absolute total for given health data type and unit for current day
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<number
>
Defined in
api/healthKit/getAbsoluteTotalForToday.ts:14
getAuthStatusForType
▸ getAuthStatusForType(key
): Promise
<HealthKitAuthStatus
>
Returns write (share) status for data type in Health API.
Parameters
Name | Type | Description |
---|---|---|
key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
Returns
Promise
<HealthKitAuthStatus
>
0 - NotDetermined, 1 - Denied, 2 - Authorized
Defined in
api/healthKit/getAuthStatusForType.ts:16
getLatestDataRecord
▸ getLatestDataRecord(options
): Promise
<HealthDataRecord
>
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<HealthDataRecord
>
Returns the latest record for specified data type and unit.
Defined in
api/healthKit/getLatestDataRecord.ts:16
getReadStatusForType
▸ getReadStatusForType(options
): Promise
<HealthKitAuthStatus
>
Deprecated
Might be deleted in future releases.
Returns read status for data type in Health API.
WARNING
! This method is unofficial. Queries for data in time span of 2 years with limit of one.
note
Try to avoid using this method and try to track user permission status in internal state.
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitDataType.Fiber |
Returns
Promise
<HealthKitAuthStatus
>
0 - if permissions was never requested.
1 - if no records were found. This could be if user never gave permissions or user has no records for this type.
2 - if records were found.
Defined in
api/healthKit/getReadStatusForType.ts:28
getStatisticTotalForToday
▸ getStatisticTotalForToday(options
): Promise
<number
>
Gets statistic total for given health data type and unit for current day, same number as in health app
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<number
>
Defined in
api/healthKit/getStatisticTotalForToday.ts:14
getStatisticTotalForWeek
▸ getStatisticTotalForWeek(options
): Promise
<number
>
Gets statistic total for given health data type and unit for current week, same number as in health app
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<number
>
Defined in
api/healthKit/getStatisticTotalForWeek.ts:14
getStatisticWeekDaily
▸ getStatisticWeekDaily(options
): Promise
<DailyData
>
Gets statistic daily total for given health data type and unit for current week, same number as in health app
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<DailyData
>
Defined in
api/healthKit/getStatisticWeekDaily.ts:15
isHealthDataAvailable
▸ isHealthDataAvailable(): Promise
<boolean
>
Returns a Boolean value that indicates whether HealthKit is available on this device.
note
HealthKit is not available on iPad.
Returns
Promise
<boolean
>
Returns true if HealthKit is available; otherwise, false.
Defined in
api/healthKit/isHealthDataAvailable.ts:14
queryAnchoredWorkouts
▸ queryAnchoredWorkouts(options?
): Promise
<HealthKitAnchoredWorkoutResult
>
Query workouts with anchor Passing anchor will return all workouts that have been added since that anchor point
Parameters
Name | Type | Description |
---|---|---|
options? | Object | - |
options.anchor? | number | last query anchor point |
options.key? | HealthKitWorkoutType | e.g. HealthKitWorkoutType.Running HealthKit |
options.limit? | number | limits the number of workouts returned from the anchor point to the newest workout |
Returns
Promise
<HealthKitAnchoredWorkoutResult
>
Returns an object with the latest anchor point and data array with new workouts
Defined in
api/healthKit/queryAnchoredWorkouts.ts:20
queryDailyTotals
▸ queryDailyTotals(options
): Promise
<{ [date: string]
: number
; }>
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate | number | Date | Unix timestamp or Date for record end date. |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.startDate | number | Date | Unix timestamp or Date for record start date. |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<{ [date: string]
: number
; }>
Returns daily totals for specified data type and unit for specified time frame
Defined in
api/healthKit/queryDailyTotals.ts:17
queryDataRecords
▸ queryDataRecords(options
): Promise
<HealthDataRecordQuery
>
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate | number | Date | Unix timestamp or Date for record end date |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.startDate | number | Date | Unix timestamp or Date for record start date |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<HealthDataRecordQuery
>
Returns every record for specified data type and unit for specified time frame
Defined in
api/healthKit/queryDataRecords.ts:18
queryTotal
▸ queryTotal(options
): Promise
<{ [date: string]
: number
; }>
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate | number | Date | Unix timestamp or Date for record end date. |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.startDate | number | Date | Unix timestamp or Date for record start date. |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<{ [date: string]
: number
; }>
Returns total for specified data type and unit for specified time frame
Defined in
api/healthKit/queryTotal.ts:17
queryWorkouts
▸ queryWorkouts(options
): Promise
<HealthWorkoutRecordQuery
>
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate | number | Date | Unix timestamp or Date for record end date |
options.key? | HealthKitWorkoutType | e.g. HealthKitWorkoutType.Running HealthKit |
options.startDate | number | Date | Unix timestamp or Date for record start date |
Returns
Promise
<HealthWorkoutRecordQuery
>
Returns workouts array for specified timeframe, filters by workout type if specified
Defined in
api/healthKit/queryWorkouts.ts:17
writeBloodPressure
▸ writeBloodPressure(options
): Promise
<boolean
>
Writes given blood pressure data to Health.
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.diastolicPressure | number | |
options.endDate | number | Date | Unix timestamp or Date for record end date. |
options.metadata? | Object | |
options.startDate | number | Date | Unix timestamp or Date for record start date. |
options.systolicPressure | number |
Returns
Promise
<boolean
>
Returns status if no errors occurred.
Defined in
api/healthKit/writeBloodPressure.ts:20
writeData
▸ writeData(options
): Promise
<boolean
>
Writes given health data to Health.
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.amount | number | |
options.key | HealthKitDataType | e.g. HealthKitDataType.Fiber |
options.metadata? | Object | |
options.timestamp? | number | optional unix timestamp for record date |
options.unit | HealthKitUnitType | e.g. HealthKitUnitType.grams |
Returns
Promise
<boolean
>
Returns status if no errors occurred.
Defined in
writeDataArray
▸ writeDataArray(dataArray
): Promise
<boolean
>
Writes given health data array to Health API
Parameters
Name | Type |
---|---|
dataArray | HealthKitWriteData [] |
Returns
Promise
<boolean
>
Returns status if no errors occurred.
Defined in
api/healthKit/writeDataArray.ts:14
writeWorkout
▸ writeWorkout(options
): Promise
<boolean
>
Records given workout data to Health API
Parameters
Name | Type | Description |
---|---|---|
options | Object | - |
options.endDate | number | Date | Unix timestamp or Date for record end date. |
options.energyBurned? | number | Number of calories in kcalHealthKit. default 0 |
options.key | HealthKitWorkoutType | e.g. HealthKitWorkoutType.Running |
options.metadata? | Object | |
options.startDate | number | Date | Unix timestamp or Date for record start date. |
options.totalDistance? | number | Total distance travelledHealthKit. default 0 |
Returns
Promise
<boolean
>
Returns status if no errors occurred.