@kingstinct/react-native-healthkit 7.2.0 → 7.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Constants.swift +1 -1
- package/ios/ReactNativeHealthkit.m +2 -1
- package/ios/ReactNativeHealthkit.swift +108 -54
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +5 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +3 -0
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +3 -0
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +3 -0
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/index.js +475 -82
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +251 -0
- package/lib/commonjs/index.native.js.map +1 -0
- package/lib/commonjs/index.web.js +17 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/jest.setup.js +2 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +5 -5
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/utils/ensureTotals.js +12 -0
- package/lib/commonjs/utils/ensureTotals.js.map +1 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js +14 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/commonjs/utils/saveCategorySample.js +4 -0
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +2 -1
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +5 -0
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +3 -0
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +3 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentWorkout.js +3 -0
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/module/index.js +195 -80
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +136 -0
- package/lib/module/index.native.js.map +1 -0
- package/lib/module/index.web.js +2 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/jest.setup.js +2 -1
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +3 -3
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/utils/ensureTotals.js +5 -0
- package/lib/module/utils/ensureTotals.js.map +1 -0
- package/lib/module/utils/getWorkoutPlanById.js +6 -0
- package/lib/module/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/module/utils/saveCategorySample.js +4 -0
- package/lib/module/utils/saveCategorySample.js.map +1 -1
- package/lib/module/utils/saveWorkoutSample.js +2 -1
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +5 -0
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +3 -0
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +3 -0
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +3 -0
- package/lib/typescript/src/index.d.ts +155 -27
- package/lib/typescript/src/index.native.d.ts +29 -0
- package/lib/typescript/src/index.web.d.ts +1 -0
- package/lib/typescript/src/native-types.d.ts +82 -75
- package/lib/typescript/src/utils/ensureTotals.d.ts +2 -0
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +5 -0
- package/lib/typescript/src/utils/saveCategorySample.d.ts +4 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +4 -0
- package/package.json +1 -1
- package/src/hooks/useHealthkitAuthorization.ts +5 -0
- package/src/hooks/useMostRecentCategorySample.ts +3 -0
- package/src/hooks/useMostRecentQuantitySample.ts +3 -0
- package/src/hooks/useMostRecentWorkout.ts +3 -0
- package/src/index.native.tsx +201 -0
- package/src/index.tsx +269 -91
- package/src/index.web.tsx +1 -0
- package/src/jest.setup.ts +2 -1
- package/src/native-types.ts +143 -116
- package/src/utils/ensureTotals.ts +5 -0
- package/src/utils/getWorkoutPlanById.ts +7 -0
- package/src/utils/saveCategorySample.ts +4 -0
- package/src/utils/saveWorkoutSample.ts +6 -0
- package/lib/commonjs/index.ios.js +0 -213
- package/lib/commonjs/index.ios.js.map +0 -1
- package/lib/module/index.ios.js +0 -191
- package/lib/module/index.ios.js.map +0 -1
- package/lib/typescript/src/index.ios.d.ts +0 -141
- package/src/index.ios.tsx +0 -217
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { HKCategoryTypeIdentifier } from '../native-types';
|
|
2
2
|
import type { HKCategorySample } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @returns the most recent sample for the given category type.
|
|
5
|
+
*/
|
|
3
6
|
declare function useMostRecentCategorySample<TCategory extends HKCategoryTypeIdentifier>(identifier: TCategory): HKCategorySample<TCategory> | null;
|
|
4
7
|
export default useMostRecentCategorySample;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { HKQuantityTypeIdentifier, UnitForIdentifier } from '../native-types';
|
|
2
2
|
import type { HKQuantitySample } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @returns the most recent sample for the given quantity type.
|
|
5
|
+
*/
|
|
3
6
|
declare function useMostRecentQuantitySample<TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: TIdentifier, unit?: TUnit): HKQuantitySample<TIdentifier, UnitForIdentifier<TIdentifier>> | null;
|
|
4
7
|
export default useMostRecentQuantitySample;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { EnergyUnit, LengthUnit } from '../native-types';
|
|
2
2
|
import type { HKWorkout } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @returns the most recent workout sample.
|
|
5
|
+
*/
|
|
3
6
|
declare function useMostRecentWorkout<TEnergy extends EnergyUnit, TDistance extends LengthUnit>(options?: {
|
|
4
7
|
readonly energyUnit?: TEnergy;
|
|
5
8
|
readonly distanceUnit?: TDistance;
|
|
@@ -1,52 +1,180 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import useHealthkitAuthorization from './hooks/useHealthkitAuthorization';
|
|
2
|
+
import useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable';
|
|
3
|
+
import useMostRecentCategorySample from './hooks/useMostRecentCategorySample';
|
|
4
|
+
import useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample';
|
|
5
|
+
import useMostRecentWorkout from './hooks/useMostRecentWorkout';
|
|
6
|
+
import useSources from './hooks/useSources';
|
|
7
|
+
import useStatisticsForQuantity from './hooks/useStatisticsForQuantity';
|
|
8
|
+
import useSubscribeToChanges from './hooks/useSubscribeToChanges';
|
|
9
|
+
import { HKQuantityTypeIdentifier } from './native-types';
|
|
10
|
+
import deleteQuantitySample from './utils/deleteQuantitySample';
|
|
11
|
+
import deleteSamples from './utils/deleteSamples';
|
|
12
|
+
import getDateOfBirth from './utils/getDateOfBirth';
|
|
13
|
+
import getMostRecentCategorySample from './utils/getMostRecentCategorySample';
|
|
14
|
+
import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample';
|
|
15
|
+
import getMostRecentWorkout from './utils/getMostRecentWorkout';
|
|
16
|
+
import getPreferredUnit from './utils/getPreferredUnit';
|
|
17
|
+
import getPreferredUnits from './utils/getPreferredUnits';
|
|
18
|
+
import getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization';
|
|
19
|
+
import getWorkoutPlanById from './utils/getWorkoutPlanById';
|
|
20
|
+
import queryCategorySamples from './utils/queryCategorySamples';
|
|
21
|
+
import queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor';
|
|
22
|
+
import queryCorrelationSamples from './utils/queryCorrelationSamples';
|
|
23
|
+
import queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples';
|
|
24
|
+
import queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor';
|
|
25
|
+
import queryQuantitySamples from './utils/queryQuantitySamples';
|
|
26
|
+
import queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor';
|
|
27
|
+
import querySources from './utils/querySources';
|
|
28
|
+
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
|
|
29
|
+
import queryWorkouts from './utils/queryWorkouts';
|
|
30
|
+
import requestAuthorization from './utils/requestAuthorization';
|
|
31
|
+
import saveCategorySample from './utils/saveCategorySample';
|
|
32
|
+
import saveCorrelationSample from './utils/saveCorrelationSample';
|
|
33
|
+
import saveQuantitySample from './utils/saveQuantitySample';
|
|
34
|
+
import saveWorkoutRoute from './utils/saveWorkoutRoute';
|
|
35
|
+
import saveWorkoutSample from './utils/saveWorkoutSample';
|
|
36
|
+
import subscribeToChanges from './utils/subscribeToChanges';
|
|
37
|
+
declare const availableQuantityTypes: (majorVersionIOS?: number) => HKQuantityTypeIdentifier[];
|
|
38
|
+
declare const authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<import("./native-types").HKAuthorizationStatus>;
|
|
39
|
+
declare const isHealthDataAvailable: () => Promise<boolean>;
|
|
40
|
+
declare const canAccessProtectedData: () => Promise<boolean>;
|
|
41
|
+
declare const disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
|
|
42
|
+
declare const disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
43
|
+
declare const enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
|
|
44
|
+
declare const getBiologicalSex: () => Promise<import("./native-types").HKBiologicalSex>;
|
|
45
|
+
declare const getFitzpatrickSkinType: () => Promise<import("./native-types").HKFitzpatrickSkinType>;
|
|
46
|
+
declare const getWheelchairUse: () => Promise<import("./native-types").HKWheelchairUse>;
|
|
47
|
+
declare const getBloodType: () => Promise<import("./native-types").HKBloodType>;
|
|
48
|
+
declare const getWorkoutRoutes: (workoutUUID: string) => Promise<readonly import("./native-types").WorkoutRoute[]>;
|
|
49
|
+
/**
|
|
50
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}
|
|
51
|
+
*/
|
|
5
52
|
declare const _default: {
|
|
6
|
-
|
|
7
|
-
|
|
53
|
+
/**
|
|
54
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }
|
|
55
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }
|
|
56
|
+
*/
|
|
57
|
+
authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<import("./native-types").HKAuthorizationStatus>;
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)
|
|
61
|
+
*/
|
|
62
|
+
availableQuantityTypes: (majorVersionIOS?: number) => HKQuantityTypeIdentifier[];
|
|
63
|
+
/**
|
|
64
|
+
* @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.
|
|
65
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}
|
|
66
|
+
* @returns {boolean} true if HealthKit is available; otherwise, false.
|
|
67
|
+
*/
|
|
8
68
|
isHealthDataAvailable: () => Promise<boolean>;
|
|
69
|
+
/**
|
|
70
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
71
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
72
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
73
|
+
*/
|
|
9
74
|
isProtectedDataAvailable: () => Promise<boolean>;
|
|
75
|
+
/**
|
|
76
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
77
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
78
|
+
* @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.
|
|
79
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
80
|
+
*/
|
|
10
81
|
canAccessProtectedData: () => Promise<boolean>;
|
|
82
|
+
/**
|
|
83
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}
|
|
84
|
+
*/
|
|
11
85
|
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
86
|
+
/**
|
|
87
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}
|
|
88
|
+
*/
|
|
12
89
|
disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
|
|
90
|
+
/**
|
|
91
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}
|
|
92
|
+
*/
|
|
13
93
|
enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
94
|
+
/**
|
|
95
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}
|
|
96
|
+
*/
|
|
97
|
+
getBiologicalSex: () => Promise<import("./native-types").HKBiologicalSex>;
|
|
98
|
+
/**
|
|
99
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}
|
|
100
|
+
*/
|
|
101
|
+
getFitzpatrickSkinType: () => Promise<import("./native-types").HKFitzpatrickSkinType>;
|
|
102
|
+
/**
|
|
103
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}
|
|
104
|
+
*/
|
|
105
|
+
getWheelchairUse: () => Promise<import("./native-types").HKWheelchairUse>;
|
|
106
|
+
/**
|
|
107
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}
|
|
108
|
+
*/
|
|
109
|
+
getBloodType: () => Promise<import("./native-types").HKBloodType>;
|
|
110
|
+
/**
|
|
111
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}
|
|
112
|
+
*/
|
|
18
113
|
getDateOfBirth: () => Promise<Date>;
|
|
19
|
-
getMostRecentQuantitySample: typeof
|
|
20
|
-
getMostRecentCategorySample: typeof
|
|
114
|
+
getMostRecentQuantitySample: typeof getMostRecentQuantitySample;
|
|
115
|
+
getMostRecentCategorySample: typeof getMostRecentCategorySample;
|
|
21
116
|
getMostRecentWorkout: import("./utils/getMostRecentWorkout").GetMostRecentWorkoutFn;
|
|
117
|
+
/**
|
|
118
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}
|
|
119
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}
|
|
120
|
+
*/
|
|
22
121
|
getWorkoutRoutes: (workoutUUID: string) => Promise<readonly import("./native-types").WorkoutRoute[]>;
|
|
122
|
+
getWorkoutPlanById: typeof getWorkoutPlanById;
|
|
23
123
|
getPreferredUnit: import("./utils/getPreferredUnit").GetPreferredUnitFn;
|
|
24
124
|
getPreferredUnits: import("./utils/getPreferredUnits").GetPreferredUnitsFn;
|
|
25
|
-
getRequestStatusForAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<HKAuthorizationRequestStatus>;
|
|
26
|
-
queryCategorySamples: QueryCategorySamplesFn;
|
|
125
|
+
getRequestStatusForAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<import("./native-types").HKAuthorizationRequestStatus>;
|
|
126
|
+
queryCategorySamples: import("./utils/queryCategorySamples").QueryCategorySamplesFn;
|
|
27
127
|
queryCategorySamplesWithAnchor: import("./utils/queryCategorySamplesWithAnchor").QueryCategorySamplesWithAnchorFn;
|
|
28
128
|
queryCorrelationSamples: import("./utils/queryCorrelationSamples").QueryCorrelationSamplesFn;
|
|
29
129
|
queryHeartbeatSeriesSamples: import("./utils/queryHeartbeatSeriesSamples").QueryHeartbeatSeriesSamplesFn;
|
|
30
130
|
queryHeartbeatSeriesSamplesWithAnchor: import("./utils/queryHeartbeatSeriesSamplesWithAnchor").QueryHeartbeatSeriesSamplesFn;
|
|
31
|
-
queryQuantitySamples: QueryQuantitySamplesFn;
|
|
131
|
+
queryQuantitySamples: import("./utils/queryQuantitySamples").QueryQuantitySamplesFn;
|
|
32
132
|
queryQuantitySamplesWithAnchor: import("./utils/queryQuantitySamplesWithAnchor").QueryQuantitySamplesWithAnchorFn;
|
|
33
|
-
queryStatisticsForQuantity: typeof
|
|
34
|
-
queryWorkouts: typeof
|
|
133
|
+
queryStatisticsForQuantity: typeof queryStatisticsForQuantity;
|
|
134
|
+
queryWorkouts: typeof queryWorkouts;
|
|
35
135
|
querySources: import("./utils/querySources").QuerySourcesFn;
|
|
36
136
|
requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
|
|
37
137
|
deleteQuantitySample: import("./utils/deleteQuantitySample").DeleteQuantitySampleFn;
|
|
38
138
|
deleteSamples: import("./utils/deleteSamples").DeleteSamplesFn;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
141
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
142
|
+
*/
|
|
143
|
+
saveCategorySample: typeof saveCategorySample;
|
|
144
|
+
saveCorrelationSample: typeof saveCorrelationSample;
|
|
145
|
+
saveQuantitySample: typeof saveQuantitySample;
|
|
146
|
+
saveWorkoutSample: typeof saveWorkoutSample;
|
|
147
|
+
saveWorkoutRoute: typeof saveWorkoutRoute;
|
|
44
148
|
subscribeToChanges: (identifier: import("./native-types").HKSampleTypeIdentifier, callback: () => void) => Promise<() => Promise<boolean>>;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
149
|
+
/**
|
|
150
|
+
* @returns the most recent sample for the given category type.
|
|
151
|
+
*/
|
|
152
|
+
useMostRecentCategorySample: typeof useMostRecentCategorySample;
|
|
153
|
+
/**
|
|
154
|
+
* @returns the most recent sample for the given quantity type.
|
|
155
|
+
*/
|
|
156
|
+
useMostRecentQuantitySample: typeof useMostRecentQuantitySample;
|
|
157
|
+
/**
|
|
158
|
+
* @returns the most recent workout sample.
|
|
159
|
+
*/
|
|
160
|
+
useMostRecentWorkout: typeof useMostRecentWorkout;
|
|
161
|
+
useSubscribeToChanges: typeof useSubscribeToChanges;
|
|
162
|
+
/**
|
|
163
|
+
* @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.
|
|
164
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}
|
|
165
|
+
* @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.
|
|
166
|
+
*/
|
|
49
167
|
useIsHealthDataAvailable: () => boolean | null;
|
|
50
|
-
|
|
168
|
+
/**
|
|
169
|
+
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
170
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
171
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
172
|
+
*/
|
|
173
|
+
useHealthkitAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[] | undefined) => readonly [import("./native-types").HKAuthorizationRequestStatus | null, () => Promise<import("./native-types").HKAuthorizationRequestStatus>];
|
|
174
|
+
useSources: typeof useSources;
|
|
175
|
+
useStatisticsForQuantity: typeof useStatisticsForQuantity;
|
|
51
176
|
};
|
|
52
177
|
export default _default;
|
|
178
|
+
declare const isProtectedDataAvailable: () => Promise<boolean>;
|
|
179
|
+
export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity, queryWorkouts, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, useSources, useStatisticsForQuantity, canAccessProtectedData, isProtectedDataAvailable, };
|
|
180
|
+
export * from './types';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnits, HKWheelchairUse } from './native-types';
|
|
2
|
+
import type ReactNativeHealthkit from '.';
|
|
3
|
+
import type { QueryCategorySamplesFn } from './utils/queryCategorySamples';
|
|
4
|
+
import type { QueryQuantitySamplesFn } from './utils/queryQuantitySamples';
|
|
5
|
+
declare const authorizationStatusFor: () => Promise<HKAuthorizationStatus>, availableQuantityTypes: () => never[], disableAllBackgroundDelivery: () => Promise<boolean>, disableBackgroundDelivery: () => Promise<boolean>, enableBackgroundDelivery: () => Promise<boolean>, getBiologicalSex: () => Promise<HKBiologicalSex>, getBloodType: () => Promise<HKBloodType>, getDateOfBirth: () => Promise<Date>, getFitzpatrickSkinType: () => Promise<HKFitzpatrickSkinType>, getMostRecentCategorySample: () => Promise<null>, getMostRecentQuantitySample: () => Promise<null>, getMostRecentWorkout: () => Promise<null>, getPreferredUnit: () => Promise<HKUnits>, getPreferredUnits: () => Promise<never[]>, getRequestStatusForAuthorization: () => Promise<HKAuthorizationRequestStatus>, getWheelchairUse: () => Promise<HKWheelchairUse>, getWorkoutRoutes: () => Promise<never[]>, isHealthDataAvailable: () => Promise<boolean>, useSources: () => null, useStatisticsForQuantity: () => null, queryCategorySamples: QueryCategorySamplesFn, queryCategorySamplesWithAnchor: () => Promise<{
|
|
6
|
+
samples: never[];
|
|
7
|
+
deletedSamples: never[];
|
|
8
|
+
newAnchor: string;
|
|
9
|
+
}>, queryCorrelationSamples: () => Promise<never[]>, queryHeartbeatSeriesSamples: () => Promise<never[]>, queryHeartbeatSeriesSamplesWithAnchor: () => Promise<{
|
|
10
|
+
samples: never[];
|
|
11
|
+
deletedSamples: never[];
|
|
12
|
+
newAnchor: string;
|
|
13
|
+
}>, queryQuantitySamples: QueryQuantitySamplesFn, queryQuantitySamplesWithAnchor: () => Promise<{
|
|
14
|
+
samples: never[];
|
|
15
|
+
deletedSamples: never[];
|
|
16
|
+
newAnchor: string;
|
|
17
|
+
}>, queryStatisticsForQuantity: () => Promise<{
|
|
18
|
+
averageQuantity: undefined;
|
|
19
|
+
maximumQuantity: undefined;
|
|
20
|
+
minimumQuantity: undefined;
|
|
21
|
+
sumQuantity: undefined;
|
|
22
|
+
mostRecentQuantity: undefined;
|
|
23
|
+
mostRecentQuantityDateInterval: undefined;
|
|
24
|
+
duration: undefined;
|
|
25
|
+
}>, queryWorkouts: () => Promise<never[]>, querySources: () => Promise<never[]>, requestAuthorization: () => Promise<boolean>, deleteQuantitySample: () => Promise<boolean>, deleteSamples: () => Promise<boolean>, getWorkoutPlanById: () => Promise<null>, saveCategorySample: () => Promise<boolean>, saveCorrelationSample: () => Promise<boolean>, saveQuantitySample: () => Promise<boolean>, saveWorkoutSample: () => Promise<null>, saveWorkoutRoute: () => Promise<boolean>, subscribeToChanges: () => Promise<() => Promise<boolean>>, useMostRecentCategorySample: () => null, useMostRecentQuantitySample: () => null, useMostRecentWorkout: () => null, useSubscribeToChanges: () => ((() => null) | null)[], useHealthkitAuthorization: () => readonly [null, () => Promise<HKAuthorizationRequestStatus>], useIsHealthDataAvailable: () => boolean, canAccessProtectedData: () => Promise<boolean>, isProtectedDataAvailable: () => Promise<boolean>;
|
|
26
|
+
declare const Healthkit: typeof ReactNativeHealthkit;
|
|
27
|
+
export { authorizationStatusFor, availableQuantityTypes, disableAllBackgroundDelivery, disableBackgroundDelivery, enableBackgroundDelivery, useSources, useStatisticsForQuantity, getBiologicalSex, getBloodType, getDateOfBirth, getFitzpatrickSkinType, getMostRecentCategorySample, getMostRecentQuantitySample, getMostRecentWorkout, getPreferredUnit, getPreferredUnits, getRequestStatusForAuthorization, getWheelchairUse, getWorkoutRoutes, isHealthDataAvailable, queryCategorySamples, queryCategorySamplesWithAnchor, queryCorrelationSamples, queryHeartbeatSeriesSamples, queryHeartbeatSeriesSamplesWithAnchor, queryQuantitySamples, queryQuantitySamplesWithAnchor, queryStatisticsForQuantity, queryWorkouts, querySources, requestAuthorization, deleteQuantitySample, deleteSamples, getWorkoutPlanById, saveCategorySample, saveCorrelationSample, saveQuantitySample, saveWorkoutSample, saveWorkoutRoute, subscribeToChanges, useMostRecentCategorySample, useMostRecentQuantitySample, useMostRecentWorkout, useSubscribeToChanges, useHealthkitAuthorization, useIsHealthDataAvailable, canAccessProtectedData, isProtectedDataAvailable, };
|
|
28
|
+
export * from './types';
|
|
29
|
+
export default Healthkit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './index.native';
|
|
@@ -9,7 +9,7 @@ export declare const HKWorkoutTypeIdentifier: "HKWorkoutTypeIdentifier";
|
|
|
9
9
|
* Represents a type that identifies activity summary objects.
|
|
10
10
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const HKActivitySummaryTypeIdentifier: "HKActivitySummaryTypeIdentifier";
|
|
13
13
|
/**
|
|
14
14
|
* Represents an audiogram type identifier.
|
|
15
15
|
* @see {@link https://developer.apple.com/documentation/healthkit/HKAudiogramSampleType Apple Docs HKAudiogramSampleType}
|
|
@@ -36,24 +36,24 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
36
36
|
*/
|
|
37
37
|
bodyMassIndex = "HKQuantityTypeIdentifierBodyMassIndex",
|
|
38
38
|
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
* Body Fat Percentage
|
|
40
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodyfatpercentage Apple Docs HKQuantityTypeIdentifierBodyFatPercentage}
|
|
41
|
+
*/
|
|
42
42
|
bodyFatPercentage = "HKQuantityTypeIdentifierBodyFatPercentage",
|
|
43
43
|
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
* Height
|
|
45
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheight Apple Docs HKQuantityTypeIdentifierHeight}
|
|
46
|
+
*/
|
|
47
47
|
height = "HKQuantityTypeIdentifierHeight",
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
* Body Mass
|
|
50
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierbodymass Apple Docs HKQuantityTypeIdentifierBodyMass}
|
|
51
|
+
*/
|
|
52
52
|
bodyMass = "HKQuantityTypeIdentifierBodyMass",
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* Lean Body Mass
|
|
55
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierleanbodymass Apple Docs HKQuantityTypeIdentifierLeanBodyMass}
|
|
56
|
+
*/
|
|
57
57
|
leanBodyMass = "HKQuantityTypeIdentifierLeanBodyMass",
|
|
58
58
|
/**
|
|
59
59
|
* Waist Circumference
|
|
@@ -180,7 +180,7 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
180
180
|
* Heart Rate Variability SDNN
|
|
181
181
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierheartratevariabilitysdnn Apple Docs HKQuantityTypeIdentifierHeartRateVariabilitySDNN}
|
|
182
182
|
* @since iOS 11.0
|
|
183
|
-
|
|
183
|
+
*/
|
|
184
184
|
heartRateVariabilitySDNN = "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
|
|
185
185
|
/**
|
|
186
186
|
* Oxygen Saturation
|
|
@@ -257,20 +257,20 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
257
257
|
*/
|
|
258
258
|
headphoneAudioExposure = "HKQuantityTypeIdentifierHeadphoneAudioExposure",
|
|
259
259
|
/**
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
260
|
+
* Dietary Fat Total
|
|
261
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfattotal Apple Docs HKQuantityTypeIdentifierDietaryFatTotal}
|
|
262
|
+
* @since iOS 8
|
|
263
|
+
*/
|
|
264
264
|
dietaryFatTotal = "HKQuantityTypeIdentifierDietaryFatTotal",
|
|
265
265
|
/**
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
266
|
+
* Dietary Fat Polyunsaturated
|
|
267
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatpolyunsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatPolyunsaturated}
|
|
268
|
+
*/
|
|
269
269
|
dietaryFatPolyunsaturated = "HKQuantityTypeIdentifierDietaryFatPolyunsaturated",
|
|
270
270
|
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
271
|
+
* Dietary Fat Monounsaturated
|
|
272
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfatmonounsaturated Apple Docs HKQuantityTypeIdentifierDietaryFatMonounsaturated}
|
|
273
|
+
*/
|
|
274
274
|
dietaryFatMonounsaturated = "HKQuantityTypeIdentifierDietaryFatMonounsaturated",
|
|
275
275
|
/**
|
|
276
276
|
* Dietary Fat Saturated
|
|
@@ -278,24 +278,24 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
278
278
|
*/
|
|
279
279
|
dietaryFatSaturated = "HKQuantityTypeIdentifierDietaryFatSaturated",
|
|
280
280
|
/**
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
* Dietary Cholesterol
|
|
282
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycholesterol Apple Docs HKQuantityTypeIdentifierDietaryCholesterol}
|
|
283
|
+
*/
|
|
284
284
|
dietaryCholesterol = "HKQuantityTypeIdentifierDietaryCholesterol",
|
|
285
285
|
/**
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
* Dietary Sodium
|
|
287
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarysodium Apple Docs HKQuantityTypeIdentifierDietarySodium}
|
|
288
|
+
*/
|
|
289
289
|
dietarySodium = "HKQuantityTypeIdentifierDietarySodium",
|
|
290
290
|
/**
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
291
|
+
* Dietary Carbohydrates
|
|
292
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarycarbohydrates Apple Docs HKQuantityTypeIdentifierDietaryCarbohydrates}
|
|
293
|
+
*/
|
|
294
294
|
dietaryCarbohydrates = "HKQuantityTypeIdentifierDietaryCarbohydrates",
|
|
295
295
|
/**
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
296
|
+
* Dietary Fiber
|
|
297
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfiber Apple Docs HKQuantityTypeIdentifierDietaryFiber}
|
|
298
|
+
*/
|
|
299
299
|
dietaryFiber = "HKQuantityTypeIdentifierDietaryFiber",
|
|
300
300
|
/**
|
|
301
301
|
* Dietary Sugar
|
|
@@ -353,49 +353,49 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
353
353
|
*/
|
|
354
354
|
dietaryCalcium = "HKQuantityTypeIdentifierDietaryCalcium",
|
|
355
355
|
/**
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
* Dietary Iron
|
|
357
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiron Apple Docs HKQuantityTypeIdentifierDietaryIron}
|
|
358
|
+
*/
|
|
359
359
|
dietaryIron = "HKQuantityTypeIdentifierDietaryIron",
|
|
360
360
|
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
* Dietary Thiamin
|
|
362
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarythiamin Apple Docs HKQuantityTypeIdentifierDietaryThiamin}
|
|
363
|
+
*/
|
|
364
364
|
dietaryThiamin = "HKQuantityTypeIdentifierDietaryThiamin",
|
|
365
365
|
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
* Dietary Riboflavin
|
|
367
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryriboflavin Apple Docs HKQuantityTypeIdentifierDietaryRiboflavin}
|
|
368
|
+
*/
|
|
369
369
|
dietaryRiboflavin = "HKQuantityTypeIdentifierDietaryRiboflavin",
|
|
370
370
|
/**
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
371
|
+
* Dietary Niacin
|
|
372
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryniacin Apple Docs HKQuantityTypeIdentifierDietaryNiacin}
|
|
373
|
+
*/
|
|
374
374
|
dietaryNiacin = "HKQuantityTypeIdentifierDietaryNiacin",
|
|
375
375
|
/**
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
376
|
+
* Dietary Folate
|
|
377
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryfolate Apple Docs HKQuantityTypeIdentifierDietaryFolate}
|
|
378
|
+
*/
|
|
379
379
|
dietaryFolate = "HKQuantityTypeIdentifierDietaryFolate",
|
|
380
380
|
/**
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
381
|
+
* Dietary Biotin
|
|
382
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarybiotin Apple Docs HKQuantityTypeIdentifierDietaryBiotin}
|
|
383
|
+
*/
|
|
384
384
|
dietaryBiotin = "HKQuantityTypeIdentifierDietaryBiotin",
|
|
385
385
|
/**
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
386
|
+
* Dietary Pantothenic Acid
|
|
387
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietarypantothenicacid Apple Docs HKQuantityTypeIdentifierDietaryPantothenicAcid}
|
|
388
|
+
*/
|
|
389
389
|
dietaryPantothenicAcid = "HKQuantityTypeIdentifierDietaryPantothenicAcid",
|
|
390
390
|
/**
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
391
|
+
* Dietary Phosphorus
|
|
392
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryphosphorus Apple Docs HKQuantityTypeIdentifierDietaryPhosphorus}
|
|
393
|
+
*/
|
|
394
394
|
dietaryPhosphorus = "HKQuantityTypeIdentifierDietaryPhosphorus",
|
|
395
395
|
/**
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
396
|
+
* Dietary Iodine
|
|
397
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierdietaryiodine Apple Docs HKQuantityTypeIdentifierDietaryIodine}
|
|
398
|
+
*/
|
|
399
399
|
dietaryIodine = "HKQuantityTypeIdentifierDietaryIodine",
|
|
400
400
|
/**
|
|
401
401
|
* Dietary Magnesium
|
|
@@ -713,7 +713,7 @@ export declare enum HKCategoryTypeIdentifier {
|
|
|
713
713
|
vomiting = "HKCategoryTypeIdentifierVomiting",
|
|
714
714
|
wheezing = "HKCategoryTypeIdentifierWheezing"
|
|
715
715
|
}
|
|
716
|
-
export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof
|
|
716
|
+
export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKActivitySummaryTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
|
|
717
717
|
export type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`;
|
|
718
718
|
export type HealthkitWriteAuthorization = HKSampleTypeIdentifier;
|
|
719
719
|
export declare enum HKCategoryValueAppleStandHour {
|
|
@@ -1392,8 +1392,8 @@ export type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdentifier> =
|
|
|
1392
1392
|
};
|
|
1393
1393
|
type QueryId = string;
|
|
1394
1394
|
/**
|
|
1395
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1396
|
-
*/
|
|
1395
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkupdatefrequency Apple Docs }
|
|
1396
|
+
*/
|
|
1397
1397
|
export declare enum HKUpdateFrequency {
|
|
1398
1398
|
immediate = 1,
|
|
1399
1399
|
hourly = 2,
|
|
@@ -1428,33 +1428,36 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1428
1428
|
getFitzpatrickSkinType(): Promise<HKFitzpatrickSkinType>;
|
|
1429
1429
|
readonly getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
1430
1430
|
/**
|
|
1431
|
-
|
|
1432
|
-
|
|
1431
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery Apple Docs }
|
|
1432
|
+
*/
|
|
1433
1433
|
readonly enableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier, updateFrequency: HKUpdateFrequency) => Promise<boolean>;
|
|
1434
1434
|
/**
|
|
1435
1435
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery Apple Docs }
|
|
1436
1436
|
*/
|
|
1437
1437
|
readonly disableBackgroundDelivery: (typeIdentifier: HKSampleTypeIdentifier) => Promise<boolean>;
|
|
1438
1438
|
/**
|
|
1439
|
-
|
|
1440
|
-
|
|
1439
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery Apple Docs }
|
|
1440
|
+
*/
|
|
1441
1441
|
readonly disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
1442
1442
|
readonly saveCorrelationSample: <TIdentifier extends HKCorrelationTypeIdentifier, TSamples extends readonly (HKCategorySampleRawForSaving | HKQuantitySampleRawForSaving)[]>(typeIdentifier: TIdentifier, samples: TSamples, start: string, end: string, metadata: MetadataMapperForCorrelationIdentifier<TIdentifier>) => Promise<boolean>;
|
|
1443
|
-
readonly saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: readonly HKQuantitySampleRawForSaving[], start: string, end: string,
|
|
1443
|
+
readonly saveWorkoutSample: (typeIdentifier: HKWorkoutActivityType, quantities: readonly HKQuantitySampleRawForSaving[], start: string, end: string, totals: {
|
|
1444
|
+
readonly distance?: number;
|
|
1445
|
+
readonly energyBurned?: number;
|
|
1446
|
+
}, metadata: HKWorkoutMetadata) => Promise<string | null>;
|
|
1444
1447
|
readonly saveWorkoutRoute: (workoutUUID: string, locations: readonly CLLocationRawForSaving[]) => Promise<boolean>;
|
|
1445
1448
|
readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, from: string, to: string) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
|
|
1446
1449
|
subscribeToObserverQuery(identifier: HKSampleTypeIdentifier): Promise<QueryId>;
|
|
1447
1450
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
1448
1451
|
/**
|
|
1449
|
-
|
|
1450
|
-
|
|
1452
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
|
|
1453
|
+
*/
|
|
1451
1454
|
authorizationStatusFor(type: HealthkitReadAuthorization): Promise<HKAuthorizationStatus>;
|
|
1452
1455
|
/**
|
|
1453
|
-
|
|
1456
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
1454
1457
|
*/
|
|
1455
1458
|
getRequestStatusForAuthorization(write: WritePermissions, read: ReadPermissions): Promise<HKAuthorizationRequestStatus>;
|
|
1456
1459
|
/**
|
|
1457
|
-
|
|
1460
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
1458
1461
|
*/
|
|
1459
1462
|
requestAuthorization(write: WritePermissions, read: ReadPermissions): Promise<boolean>;
|
|
1460
1463
|
readonly saveQuantitySample: <TType extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TType> = UnitForIdentifier<TType>>(identifier: TType, unit: TUnit, value: number, start: string, end: string, metadata: unknown) => Promise<boolean>;
|
|
@@ -1472,6 +1475,10 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1472
1475
|
readonly queryStatisticsForQuantity: <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends UnitForIdentifier<TIdentifier>>(identifier: HKQuantityTypeIdentifier, unit: TUnit, from: string, to: string, options: readonly HKStatisticsOptions[]) => Promise<QueryStatisticsResponseRaw<TIdentifier, TUnit>>;
|
|
1473
1476
|
readonly getPreferredUnits: (identifiers: readonly HKQuantityTypeIdentifier[]) => Promise<TypeToUnitMapping>;
|
|
1474
1477
|
readonly getWorkoutRoutes: (workoutUUID: string) => Promise<readonly WorkoutRoute[]>;
|
|
1478
|
+
readonly getWorkoutPlanById: (workoutUUID: string) => Promise<{
|
|
1479
|
+
readonly id: string;
|
|
1480
|
+
readonly activityType: HKWorkoutActivityType;
|
|
1481
|
+
} | null>;
|
|
1475
1482
|
};
|
|
1476
1483
|
declare const Native: ReactNativeHealthkitTypeNative;
|
|
1477
1484
|
type OnChangeCallback = ({ typeIdentifier, }: {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, MetadataMapperForCategoryIdentifier } from '../native-types';
|
|
2
|
+
/**
|
|
3
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
4
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
5
|
+
*/
|
|
2
6
|
declare function saveCategorySample<T extends HKCategoryTypeIdentifier>(identifier: T, value: HKCategoryValueForIdentifier<T>, options?: {
|
|
3
7
|
readonly start?: Date;
|
|
4
8
|
readonly end?: Date;
|
|
@@ -2,6 +2,10 @@ import type { HKWorkoutActivityType, HKWorkoutMetadata } from '../native-types';
|
|
|
2
2
|
import type { HKQuantitySampleForSaving } from '../types';
|
|
3
3
|
declare function saveWorkoutSample<TIdentifier extends HKWorkoutActivityType>(typeIdentifier: TIdentifier, quantities: readonly HKQuantitySampleForSaving[], _start: Date, options?: {
|
|
4
4
|
readonly end?: Date;
|
|
5
|
+
readonly totals?: {
|
|
6
|
+
readonly distance?: number;
|
|
7
|
+
readonly energyBurned?: number;
|
|
8
|
+
};
|
|
5
9
|
readonly metadata?: HKWorkoutMetadata;
|
|
6
10
|
}): Promise<string | null>;
|
|
7
11
|
export default saveWorkoutSample;
|
package/package.json
CHANGED
|
@@ -7,6 +7,11 @@ import requestAuthorization from '../utils/requestAuthorization'
|
|
|
7
7
|
|
|
8
8
|
import type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus } from '../native-types'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
12
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
13
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
14
|
+
*/
|
|
10
15
|
const useHealthkitAuthorization = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => {
|
|
11
16
|
const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)
|
|
12
17
|
|