@kingstinct/react-native-healthkit 7.0.4 → 7.0.6
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/README.md +7 -31
- package/ios/ReactNativeHealthkit.swift +3 -2
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +5 -0
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/commonjs/index.ios.js +121 -15
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +1 -0
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +36 -27
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +5 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js +6 -0
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/module/index.ios.js +119 -15
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +1 -0
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +36 -27
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +59 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +5 -1
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +5 -0
- package/lib/typescript/src/index.d.ts +50 -3
- package/lib/typescript/src/index.ios.d.ts +84 -3
- package/lib/typescript/src/native-types.d.ts +515 -34
- package/lib/typescript/src/types.d.ts +49 -0
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +2 -1
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +2 -1
- package/package.json +1 -1
- package/src/hooks/useIsHealthDataAvailable.ts +5 -0
- package/src/index.ios.tsx +132 -21
- package/src/index.tsx +6 -4
- package/src/jest.setup.ts +1 -0
- package/src/native-types.ts +615 -81
- package/src/types.ts +51 -2
- package/src/utils/getMostRecentCategorySample.ts +3 -2
- package/src/utils/getMostRecentQuantitySample.ts +9 -2
|
@@ -1,4 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { HKAuthorizationRequestStatus, HKAuthorizationStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKWheelchairUse } from './native-types';
|
|
2
|
+
import type { QueryCategorySamplesFn } from './utils/queryCategorySamples';
|
|
3
|
+
import type { QueryQuantitySamplesFn } from './utils/queryQuantitySamples';
|
|
3
4
|
export * from './types';
|
|
4
|
-
|
|
5
|
+
declare const _default: {
|
|
6
|
+
authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<HKAuthorizationStatus>;
|
|
7
|
+
availableQuantityTypes: (majorVersionIOS?: number) => import("./native-types").HKQuantityTypeIdentifier[];
|
|
8
|
+
isHealthDataAvailable: () => Promise<boolean>;
|
|
9
|
+
isProtectedDataAvailable: () => Promise<boolean>;
|
|
10
|
+
canAccessProtectedData: () => Promise<boolean>;
|
|
11
|
+
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
12
|
+
disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
|
|
13
|
+
enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
|
|
14
|
+
getBiologicalSex: () => Promise<HKBiologicalSex>;
|
|
15
|
+
getFitzpatrickSkinType: () => Promise<HKFitzpatrickSkinType>;
|
|
16
|
+
getWheelchairUse: () => Promise<HKWheelchairUse>;
|
|
17
|
+
getBloodType: () => Promise<HKBloodType>;
|
|
18
|
+
getDateOfBirth: () => Promise<Date>;
|
|
19
|
+
getMostRecentQuantitySample: typeof import("./utils/getMostRecentQuantitySample").default;
|
|
20
|
+
getMostRecentCategorySample: typeof import("./utils/getMostRecentCategorySample").default;
|
|
21
|
+
getMostRecentWorkout: import("./utils/getMostRecentWorkout").GetMostRecentWorkoutFn;
|
|
22
|
+
getWorkoutRoutes: (workoutUUID: string) => Promise<readonly import("./native-types").WorkoutRoute[]>;
|
|
23
|
+
getPreferredUnit: import("./utils/getPreferredUnit").GetPreferredUnitFn;
|
|
24
|
+
getPreferredUnits: import("./utils/getPreferredUnits").GetPreferredUnitsFn;
|
|
25
|
+
getRequestStatusForAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<HKAuthorizationRequestStatus>;
|
|
26
|
+
queryCategorySamples: QueryCategorySamplesFn;
|
|
27
|
+
queryCategorySamplesWithAnchor: import("./utils/queryCategorySamplesWithAnchor").QueryCategorySamplesWithAnchorFn;
|
|
28
|
+
queryCorrelationSamples: import("./utils/queryCorrelationSamples").QueryCorrelationSamplesFn;
|
|
29
|
+
queryHeartbeatSeriesSamples: import("./utils/queryHeartbeatSeriesSamples").QueryHeartbeatSeriesSamplesFn;
|
|
30
|
+
queryHeartbeatSeriesSamplesWithAnchor: import("./utils/queryHeartbeatSeriesSamplesWithAnchor").QueryHeartbeatSeriesSamplesFn;
|
|
31
|
+
queryQuantitySamples: QueryQuantitySamplesFn;
|
|
32
|
+
queryQuantitySamplesWithAnchor: import("./utils/queryQuantitySamplesWithAnchor").QueryQuantitySamplesWithAnchorFn;
|
|
33
|
+
queryStatisticsForQuantity: typeof import("./utils/queryStatisticsForQuantity").default;
|
|
34
|
+
queryWorkouts: typeof import("./utils/queryWorkouts").default;
|
|
35
|
+
querySources: import("./utils/querySources").QuerySourcesFn;
|
|
36
|
+
requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
|
|
37
|
+
deleteQuantitySample: import("./utils/deleteQuantitySample").DeleteQuantitySampleFn;
|
|
38
|
+
deleteSamples: import("./utils/deleteSamples").DeleteSamplesFn;
|
|
39
|
+
saveCategorySample: typeof import("./utils/saveCategorySample").default;
|
|
40
|
+
saveCorrelationSample: typeof import("./utils/saveCorrelationSample").default;
|
|
41
|
+
saveQuantitySample: typeof import("./utils/saveQuantitySample").default;
|
|
42
|
+
saveWorkoutSample: typeof import("./utils/saveWorkoutSample").default;
|
|
43
|
+
subscribeToChanges: (identifier: import("./native-types").HKSampleTypeIdentifier, callback: () => void) => Promise<() => Promise<boolean>>;
|
|
44
|
+
useMostRecentCategorySample: typeof import("./hooks/useMostRecentCategorySample").default;
|
|
45
|
+
useMostRecentQuantitySample: typeof import("./hooks/useMostRecentQuantitySample").default;
|
|
46
|
+
useMostRecentWorkout: typeof import("./hooks/useMostRecentWorkout").default;
|
|
47
|
+
useSubscribeToChanges: typeof import("./hooks/useSubscribeToChanges").default;
|
|
48
|
+
useIsHealthDataAvailable: () => boolean | null;
|
|
49
|
+
useHealthkitAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[] | undefined) => readonly [HKAuthorizationRequestStatus | null, () => Promise<HKAuthorizationRequestStatus>];
|
|
50
|
+
};
|
|
51
|
+
export default _default;
|
|
@@ -2,6 +2,7 @@ import useMostRecentCategorySample from './hooks/useMostRecentCategorySample';
|
|
|
2
2
|
import useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample';
|
|
3
3
|
import useMostRecentWorkout from './hooks/useMostRecentWorkout';
|
|
4
4
|
import useSubscribeToChanges from './hooks/useSubscribeToChanges';
|
|
5
|
+
import { HKQuantityTypeIdentifier } from './native-types';
|
|
5
6
|
import getMostRecentCategorySample from './utils/getMostRecentCategorySample';
|
|
6
7
|
import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample';
|
|
7
8
|
import queryStatisticsForQuantity from './utils/queryStatisticsForQuantity';
|
|
@@ -10,22 +11,79 @@ import saveCategorySample from './utils/saveCategorySample';
|
|
|
10
11
|
import saveCorrelationSample from './utils/saveCorrelationSample';
|
|
11
12
|
import saveQuantitySample from './utils/saveQuantitySample';
|
|
12
13
|
import saveWorkoutSample from './utils/saveWorkoutSample';
|
|
13
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}
|
|
16
|
+
*/
|
|
17
|
+
declare const _default: {
|
|
18
|
+
/**
|
|
19
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }
|
|
20
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }
|
|
21
|
+
*/
|
|
14
22
|
authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<import("./native-types").HKAuthorizationStatus>;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)
|
|
26
|
+
*/
|
|
27
|
+
availableQuantityTypes: (majorVersionIOS?: number) => HKQuantityTypeIdentifier[];
|
|
28
|
+
/**
|
|
29
|
+
* @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.
|
|
30
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}
|
|
31
|
+
* @returns {boolean} true if HealthKit is available; otherwise, false.
|
|
32
|
+
*/
|
|
15
33
|
isHealthDataAvailable: () => Promise<boolean>;
|
|
34
|
+
/**
|
|
35
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
36
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
37
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
38
|
+
*/
|
|
39
|
+
isProtectedDataAvailable: () => Promise<boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
42
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
43
|
+
* @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.
|
|
44
|
+
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
45
|
+
*/
|
|
16
46
|
canAccessProtectedData: () => Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}
|
|
49
|
+
*/
|
|
17
50
|
disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}
|
|
53
|
+
*/
|
|
18
54
|
disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}
|
|
57
|
+
*/
|
|
19
58
|
enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
|
|
59
|
+
/**
|
|
60
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}
|
|
61
|
+
*/
|
|
20
62
|
getBiologicalSex: () => Promise<import("./native-types").HKBiologicalSex>;
|
|
63
|
+
/**
|
|
64
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}
|
|
65
|
+
*/
|
|
21
66
|
getFitzpatrickSkinType: () => Promise<import("./native-types").HKFitzpatrickSkinType>;
|
|
67
|
+
/**
|
|
68
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}
|
|
69
|
+
*/
|
|
22
70
|
getWheelchairUse: () => Promise<import("./native-types").HKWheelchairUse>;
|
|
71
|
+
/**
|
|
72
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}
|
|
73
|
+
*/
|
|
23
74
|
getBloodType: () => Promise<import("./native-types").HKBloodType>;
|
|
24
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}
|
|
77
|
+
*/
|
|
25
78
|
getDateOfBirth: () => Promise<Date>;
|
|
26
79
|
getMostRecentQuantitySample: typeof getMostRecentQuantitySample;
|
|
27
80
|
getMostRecentCategorySample: typeof getMostRecentCategorySample;
|
|
28
81
|
getMostRecentWorkout: import("./utils/getMostRecentWorkout").GetMostRecentWorkoutFn;
|
|
82
|
+
/**
|
|
83
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}
|
|
84
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}
|
|
85
|
+
*/
|
|
86
|
+
getWorkoutRoutes: (workoutUUID: string) => Promise<readonly import("./native-types").WorkoutRoute[]>;
|
|
29
87
|
getPreferredUnit: import("./utils/getPreferredUnit").GetPreferredUnitFn;
|
|
30
88
|
getPreferredUnits: import("./utils/getPreferredUnits").GetPreferredUnitsFn;
|
|
31
89
|
getRequestStatusForAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<import("./native-types").HKAuthorizationRequestStatus>;
|
|
@@ -42,17 +100,40 @@ declare const Healthkit: {
|
|
|
42
100
|
requestAuthorization: (read: readonly import("./native-types").HealthkitReadAuthorization[], write?: readonly import("./native-types").HKSampleTypeIdentifier[]) => Promise<boolean>;
|
|
43
101
|
deleteQuantitySample: import("./utils/deleteQuantitySample").DeleteQuantitySampleFn;
|
|
44
102
|
deleteSamples: import("./utils/deleteSamples").DeleteSamplesFn;
|
|
103
|
+
/**
|
|
104
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}
|
|
105
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}
|
|
106
|
+
*/
|
|
45
107
|
saveCategorySample: typeof saveCategorySample;
|
|
46
108
|
saveCorrelationSample: typeof saveCorrelationSample;
|
|
47
109
|
saveQuantitySample: typeof saveQuantitySample;
|
|
48
110
|
saveWorkoutSample: typeof saveWorkoutSample;
|
|
49
111
|
subscribeToChanges: (identifier: import("./native-types").HKSampleTypeIdentifier, callback: () => void) => Promise<() => Promise<boolean>>;
|
|
112
|
+
/**
|
|
113
|
+
* @returns the most recent sample for the given category type.
|
|
114
|
+
*/
|
|
50
115
|
useMostRecentCategorySample: typeof useMostRecentCategorySample;
|
|
116
|
+
/**
|
|
117
|
+
* @returns the most recent sample for the given quantity type.
|
|
118
|
+
*/
|
|
51
119
|
useMostRecentQuantitySample: typeof useMostRecentQuantitySample;
|
|
120
|
+
/**
|
|
121
|
+
* @returns the most recent workout sample.
|
|
122
|
+
*/
|
|
52
123
|
useMostRecentWorkout: typeof useMostRecentWorkout;
|
|
53
124
|
useSubscribeToChanges: typeof useSubscribeToChanges;
|
|
125
|
+
/**
|
|
126
|
+
* @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.
|
|
127
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}
|
|
128
|
+
* @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.
|
|
129
|
+
*/
|
|
54
130
|
useIsHealthDataAvailable: () => boolean | null;
|
|
131
|
+
/**
|
|
132
|
+
* @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.
|
|
133
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
134
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
135
|
+
*/
|
|
55
136
|
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>];
|
|
56
137
|
};
|
|
138
|
+
export default _default;
|
|
57
139
|
export * from './types';
|
|
58
|
-
export default Healthkit;
|