Skip to main content

Namespace: HealthKit

Functions​

authorize​

▸ authorize(shareTypes, readTypes): Promise<boolean>

Sets up health tracking and returns status

Parameters​

NameTypeDescription
shareTypesHealthKitDataType[]e.g. [HealthKitDataType.Fiber]
readTypesHealthKitDataType[]e.g. [HealthKitDataType.Fiber]

Returns​

Promise<boolean>

Returns status if no errors occurred.

Defined in​

api/healthKit/authorize.ts:16


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​

NameTypeDescription
optionsObject-
options.endDate?number | DateUnix timestamp or Date for record end date.
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.startDate?number | DateUnix timestamp or Date for record start date.
options.uuid?stringUnique 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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
keyHealthKitDataTypee.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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.unitHealthKitUnitTypee.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​

NameTypeDescription
options?Object-
options.anchor?numberlast query anchor point
options.key?HealthKitWorkoutTypee.g. HealthKitWorkoutType.RunningHealthKit
options.limit?numberlimits 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​

NameTypeDescription
optionsObject-
options.endDatenumber | DateUnix timestamp or Date for record end date.
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.startDatenumber | DateUnix timestamp or Date for record start date.
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.endDatenumber | DateUnix timestamp or Date for record end date
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.startDatenumber | DateUnix timestamp or Date for record start date
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.endDatenumber | DateUnix timestamp or Date for record end date.
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.startDatenumber | DateUnix timestamp or Date for record start date.
options.unitHealthKitUnitTypee.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​

NameTypeDescription
optionsObject-
options.endDatenumber | DateUnix timestamp or Date for record end date
options.key?HealthKitWorkoutTypee.g. HealthKitWorkoutType.RunningHealthKit
options.startDatenumber | DateUnix 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​

NameTypeDescription
optionsObject-
options.diastolicPressurenumber
options.endDatenumber | DateUnix timestamp or Date for record end date.
options.metadata?Object
options.startDatenumber | DateUnix timestamp or Date for record start date.
options.systolicPressurenumber

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​

NameTypeDescription
optionsObject-
options.amountnumber
options.keyHealthKitDataTypee.g. HealthKitDataType.Fiber
options.metadata?Object
options.timestamp?numberoptional unix timestamp for record date
options.unitHealthKitUnitTypee.g. HealthKitUnitType.grams

Returns​

Promise<boolean>

Returns status if no errors occurred.

Defined in​

api/healthKit/writeData.ts:21


writeDataArray​

▸ writeDataArray(dataArray): Promise<boolean>

Writes given health data array to Health API

Parameters​

NameType
dataArrayHealthKitWriteData[]

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​

NameTypeDescription
optionsObject-
options.endDatenumber | DateUnix timestamp or Date for record end date.
options.energyBurned?numberNumber of calories in kcalHealthKit. default 0
options.keyHealthKitWorkoutTypee.g. HealthKitWorkoutType.Running
options.metadata?Object
options.startDatenumber | DateUnix timestamp or Date for record start date.
options.totalDistance?numberTotal distance travelledHealthKit. default 0

Returns​

Promise<boolean>

Returns status if no errors occurred.

Defined in​

api/healthKit/writeWorkout.ts:22