@kingstinct/react-native-healthkit 4.4.0 → 4.4.3
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/lib/commonjs/index.ios.js +31 -1
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +49 -36
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-types.js +111 -104
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/index.ios.js +32 -2
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +50 -36
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-types.js +109 -102
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +113 -105
- package/lib/typescript/src/types.d.ts +7 -5
- package/package.json +1 -1
- package/src/index.ios.tsx +42 -7
- package/src/index.tsx +53 -36
- package/src/native-types.ts +149 -137
- package/src/types.ts +13 -7
|
@@ -1,10 +1,101 @@
|
|
|
1
1
|
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import type { EmitterSubscription } from 'react-native';
|
|
3
|
-
export declare const HKWorkoutTypeIdentifier
|
|
4
|
-
export declare const HKAudiogramTypeIdentifier
|
|
5
|
-
export declare const HKWorkoutRouteTypeIdentifier
|
|
6
|
-
export declare const HKDataTypeIdentifierHeartbeatSeries
|
|
7
|
-
export declare
|
|
3
|
+
export declare const HKWorkoutTypeIdentifier: "HKWorkoutTypeIdentifier";
|
|
4
|
+
export declare const HKAudiogramTypeIdentifier: "HKAudiogramTypeIdentifier";
|
|
5
|
+
export declare const HKWorkoutRouteTypeIdentifier: "HKWorkoutRouteTypeIdentifier";
|
|
6
|
+
export declare const HKDataTypeIdentifierHeartbeatSeries: "HKDataTypeIdentifierHeartbeatSeries";
|
|
7
|
+
export declare enum HKQuantityTypeIdentifier {
|
|
8
|
+
bodyMassIndex = "HKQuantityTypeIdentifierBodyMassIndex",
|
|
9
|
+
bodyFatPercentage = "HKQuantityTypeIdentifierBodyFatPercentage",
|
|
10
|
+
height = "HKQuantityTypeIdentifierHeight",
|
|
11
|
+
bodyMass = "HKQuantityTypeIdentifierBodyMass",
|
|
12
|
+
leanBodyMass = "HKQuantityTypeIdentifierLeanBodyMass",
|
|
13
|
+
waistCircumference = "HKQuantityTypeIdentifierWaistCircumference",
|
|
14
|
+
stepCount = "HKQuantityTypeIdentifierStepCount",
|
|
15
|
+
distanceWalkingRunning = "HKQuantityTypeIdentifierDistanceWalkingRunning",
|
|
16
|
+
distanceCycling = "HKQuantityTypeIdentifierDistanceCycling",
|
|
17
|
+
distanceWheelchair = "HKQuantityTypeIdentifierDistanceWheelchair",
|
|
18
|
+
basalEnergyBurned = "HKQuantityTypeIdentifierBasalEnergyBurned",
|
|
19
|
+
activeEnergyBurned = "HKQuantityTypeIdentifierActiveEnergyBurned",
|
|
20
|
+
flightsClimbed = "HKQuantityTypeIdentifierFlightsClimbed",
|
|
21
|
+
nikeFuel = "HKQuantityTypeIdentifierNikeFuel",
|
|
22
|
+
appleExerciseTime = "HKQuantityTypeIdentifierAppleExerciseTime",
|
|
23
|
+
pushCount = "HKQuantityTypeIdentifierPushCount",
|
|
24
|
+
distanceSwimming = "HKQuantityTypeIdentifierDistanceSwimming",
|
|
25
|
+
swimmingStrokeCount = "HKQuantityTypeIdentifierSwimmingStrokeCount",
|
|
26
|
+
vo2Max = "HKQuantityTypeIdentifierVo2Max",
|
|
27
|
+
distanceDownhillSnowSports = "HKQuantityTypeIdentifierDistanceDownhillSnowSports",
|
|
28
|
+
appleStandTime = "HKQuantityTypeIdentifierAppleStandTime",
|
|
29
|
+
heartRate = "HKQuantityTypeIdentifierHeartRate",
|
|
30
|
+
bodyTemperature = "HKQuantityTypeIdentifierBodyTemperature",
|
|
31
|
+
basalBodyTemperature = "HKQuantityTypeIdentifierBasalBodyTemperature",
|
|
32
|
+
bloodPressureSystolic = "HKQuantityTypeIdentifierBloodPressureSystolic",
|
|
33
|
+
bloodPressureDiastolic = "HKQuantityTypeIdentifierBloodPressureDiastolic",
|
|
34
|
+
respiratoryRate = "HKQuantityTypeIdentifierRespiratoryRate",
|
|
35
|
+
restingHeartRate = "HKQuantityTypeIdentifierRestingHeartRate",
|
|
36
|
+
walkingHeartRateAverage = "HKQuantityTypeIdentifierWalkingHeartRateAverage",
|
|
37
|
+
heartRateVariabilitySDNN = "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
|
|
38
|
+
oxygenSaturation = "HKQuantityTypeIdentifierOxygenSaturation",
|
|
39
|
+
peripheralPerfusionIndex = "HKQuantityTypeIdentifierPeripheralPerfusionIndex",
|
|
40
|
+
bloodGlucose = "HKQuantityTypeIdentifierBloodGlucose",
|
|
41
|
+
numberOfTimesFallen = "HKQuantityTypeIdentifierNumberOfTimesFallen",
|
|
42
|
+
electrodermalActivity = "HKQuantityTypeIdentifierElectrodermalActivity",
|
|
43
|
+
inhalerUsage = "HKQuantityTypeIdentifierInhalerUsage",
|
|
44
|
+
insulinDelivery = "HKQuantityTypeIdentifierInsulinDelivery",
|
|
45
|
+
bloodAlcoholContent = "HKQuantityTypeIdentifierBloodAlcoholContent",
|
|
46
|
+
forcedVitalCapacity = "HKQuantityTypeIdentifierForcedVitalCapacity",
|
|
47
|
+
forcedExpiratoryVolume1 = "HKQuantityTypeIdentifierForcedExpiratoryVolume1",
|
|
48
|
+
peakExpiratoryFlowRate = "HKQuantityTypeIdentifierPeakExpiratoryFlowRate",
|
|
49
|
+
environmentalAudioExposure = "HKQuantityTypeIdentifierEnvironmentalAudioExposure",
|
|
50
|
+
headphoneAudioExposure = "HKQuantityTypeIdentifierHeadphoneAudioExposure",
|
|
51
|
+
dietaryFatTotal = "HKQuantityTypeIdentifierDietaryFatTotal",
|
|
52
|
+
dietaryFatPolyunsaturated = "HKQuantityTypeIdentifierDietaryFatPolyunsaturated",
|
|
53
|
+
dietaryFatMonounsaturated = "HKQuantityTypeIdentifierDietaryFatMonounsaturated",
|
|
54
|
+
dietaryFatSaturated = "HKQuantityTypeIdentifierDietaryFatSaturated",
|
|
55
|
+
dietaryCholesterol = "HKQuantityTypeIdentifierDietaryCholesterol",
|
|
56
|
+
dietarySodium = "HKQuantityTypeIdentifierDietarySodium",
|
|
57
|
+
dietaryCarbohydrates = "HKQuantityTypeIdentifierDietaryCarbohydrates",
|
|
58
|
+
dietaryFiber = "HKQuantityTypeIdentifierDietaryFiber",
|
|
59
|
+
dietarySugar = "HKQuantityTypeIdentifierDietarySugar",
|
|
60
|
+
dietaryEnergyConsumed = "HKQuantityTypeIdentifierDietaryEnergyConsumed",
|
|
61
|
+
dietaryProtein = "HKQuantityTypeIdentifierDietaryProtein",
|
|
62
|
+
dietaryVitaminA = "HKQuantityTypeIdentifierDietaryVitaminA",
|
|
63
|
+
dietaryVitaminB6 = "HKQuantityTypeIdentifierDietaryVitaminB6",
|
|
64
|
+
dietaryVitaminB12 = "HKQuantityTypeIdentifierDietaryVitaminB12",
|
|
65
|
+
dietaryVitaminC = "HKQuantityTypeIdentifierDietaryVitaminC",
|
|
66
|
+
dietaryVitaminD = "HKQuantityTypeIdentifierDietaryVitaminD",
|
|
67
|
+
dietaryVitaminE = "HKQuantityTypeIdentifierDietaryVitaminE",
|
|
68
|
+
dietaryVitaminK = "HKQuantityTypeIdentifierDietaryVitaminK",
|
|
69
|
+
dietaryCalcium = "HKQuantityTypeIdentifierDietaryCalcium",
|
|
70
|
+
dietaryIron = "HKQuantityTypeIdentifierDietaryIron",
|
|
71
|
+
dietaryThiamin = "HKQuantityTypeIdentifierDietaryThiamin",
|
|
72
|
+
dietaryRiboflavin = "HKQuantityTypeIdentifierDietaryRiboflavin",
|
|
73
|
+
dietaryNiacin = "HKQuantityTypeIdentifierDietaryNiacin",
|
|
74
|
+
dietaryFolate = "HKQuantityTypeIdentifierDietaryFolate",
|
|
75
|
+
dietaryBiotin = "HKQuantityTypeIdentifierDietaryBiotin",
|
|
76
|
+
dietaryPantothenicAcid = "HKQuantityTypeIdentifierDietaryPantothenicAcid",
|
|
77
|
+
dietaryPhosphorus = "HKQuantityTypeIdentifierDietaryPhosphorus",
|
|
78
|
+
dietaryIodine = "HKQuantityTypeIdentifierDietaryIodine",
|
|
79
|
+
dietaryMagnesium = "HKQuantityTypeIdentifierDietaryMagnesium",
|
|
80
|
+
dietaryZinc = "HKQuantityTypeIdentifierDietaryZinc",
|
|
81
|
+
dietarySelenium = "HKQuantityTypeIdentifierDietarySelenium",
|
|
82
|
+
dietaryCopper = "HKQuantityTypeIdentifierDietaryCopper",
|
|
83
|
+
dietaryManganese = "HKQuantityTypeIdentifierDietaryManganese",
|
|
84
|
+
dietaryChromium = "HKQuantityTypeIdentifierDietaryChromium",
|
|
85
|
+
dietaryMolybdenum = "HKQuantityTypeIdentifierDietaryMolybdenum",
|
|
86
|
+
dietaryChloride = "HKQuantityTypeIdentifierDietaryChloride",
|
|
87
|
+
dietaryPotassium = "HKQuantityTypeIdentifierDietaryPotassium",
|
|
88
|
+
dietaryCaffeine = "HKQuantityTypeIdentifierDietaryCaffeine",
|
|
89
|
+
dietaryWater = "HKQuantityTypeIdentifierDietaryWater",
|
|
90
|
+
sixMinuteWalkTestDistance = "HKQuantityTypeIdentifierSixMinuteWalkTestDistance",
|
|
91
|
+
walkingSpeed = "HKQuantityTypeIdentifierWalkingSpeed",
|
|
92
|
+
walkingStepLength = "HKQuantityTypeIdentifierWalkingStepLength",
|
|
93
|
+
walkingAsymmetryPercentage = "HKQuantityTypeIdentifierWalkingAsymmetryPercentage",
|
|
94
|
+
walkingDoubleSupportPercentage = "HKQuantityTypeIdentifierWalkingDoubleSupportPercentage",
|
|
95
|
+
stairAscentSpeed = "HKQuantityTypeIdentifierStairAscentSpeed",
|
|
96
|
+
stairDescentSpeed = "HKQuantityTypeIdentifierStairDescentSpeed",
|
|
97
|
+
uvExposure = "HKQuantityTypeIdentifierUvExposure"
|
|
98
|
+
}
|
|
8
99
|
export declare type TypeToUnitMapping = {
|
|
9
100
|
readonly [key in HKQuantityTypeIdentifier]: HKUnit;
|
|
10
101
|
};
|
|
@@ -13,6 +104,10 @@ export declare enum HKHeartRateMotionContext {
|
|
|
13
104
|
notSet = 0,
|
|
14
105
|
sedentary = 1
|
|
15
106
|
}
|
|
107
|
+
export declare enum HKCorrelationTypeIdentifier {
|
|
108
|
+
bloodPressure = "HKCorrelationTypeIdentifierBloodPressure",
|
|
109
|
+
food = "HKCorrelationTypeIdentifierFood"
|
|
110
|
+
}
|
|
16
111
|
export declare enum HKCategoryTypeIdentifier {
|
|
17
112
|
sleepAnalysis = "HKCategoryTypeIdentifierSleepAnalysis",
|
|
18
113
|
appleStandHour = "HKCategoryTypeIdentifierAppleStandHour",
|
|
@@ -28,6 +123,9 @@ export declare enum HKCategoryTypeIdentifier {
|
|
|
28
123
|
audioExposureEvent = "HKCategoryTypeIdentifierAudioExposureEvent",
|
|
29
124
|
toothbrushingEvent = "HKCategoryTypeIdentifierToothbrushingEvent"
|
|
30
125
|
}
|
|
126
|
+
export declare type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
|
|
127
|
+
export declare type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`;
|
|
128
|
+
export declare type HealthkitWriteAuthorization = HKSampleTypeIdentifier;
|
|
31
129
|
export declare enum HKCategoryValueAppleStandHour {
|
|
32
130
|
stood = 0,
|
|
33
131
|
idle = 1
|
|
@@ -158,101 +256,16 @@ export declare enum HKWeatherCondition {
|
|
|
158
256
|
hurricane = 26,
|
|
159
257
|
tornado = 27
|
|
160
258
|
}
|
|
259
|
+
declare enum HKIndoorWorkout {
|
|
260
|
+
false = 0,
|
|
261
|
+
true = 1
|
|
262
|
+
}
|
|
161
263
|
export interface HKWorkoutMetadata extends HKGenericMetadata {
|
|
162
264
|
readonly HKWeatherCondition?: HKWeatherCondition;
|
|
163
265
|
readonly HKWeatherHumidity?: HKQuantity<HKUnit.Percent>;
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
bodyFatPercentage = "HKQuantityTypeIdentifierBodyFatPercentage",
|
|
168
|
-
height = "HKQuantityTypeIdentifierHeight",
|
|
169
|
-
bodyMass = "HKQuantityTypeIdentifierBodyMass",
|
|
170
|
-
leanBodyMass = "HKQuantityTypeIdentifierLeanBodyMass",
|
|
171
|
-
waistCircumference = "HKQuantityTypeIdentifierWaistCircumference",
|
|
172
|
-
stepCount = "HKQuantityTypeIdentifierStepCount",
|
|
173
|
-
distanceWalkingRunning = "HKQuantityTypeIdentifierDistanceWalkingRunning",
|
|
174
|
-
distanceCycling = "HKQuantityTypeIdentifierDistanceCycling",
|
|
175
|
-
distanceWheelchair = "HKQuantityTypeIdentifierDistanceWheelchair",
|
|
176
|
-
basalEnergyBurned = "HKQuantityTypeIdentifierBasalEnergyBurned",
|
|
177
|
-
activeEnergyBurned = "HKQuantityTypeIdentifierActiveEnergyBurned",
|
|
178
|
-
flightsClimbed = "HKQuantityTypeIdentifierFlightsClimbed",
|
|
179
|
-
nikeFuel = "HKQuantityTypeIdentifierNikeFuel",
|
|
180
|
-
appleExerciseTime = "HKQuantityTypeIdentifierAppleExerciseTime",
|
|
181
|
-
pushCount = "HKQuantityTypeIdentifierPushCount",
|
|
182
|
-
distanceSwimming = "HKQuantityTypeIdentifierDistanceSwimming",
|
|
183
|
-
swimmingStrokeCount = "HKQuantityTypeIdentifierSwimmingStrokeCount",
|
|
184
|
-
vo2Max = "HKQuantityTypeIdentifierVo2Max",
|
|
185
|
-
distanceDownhillSnowSports = "HKQuantityTypeIdentifierDistanceDownhillSnowSports",
|
|
186
|
-
appleStandTime = "HKQuantityTypeIdentifierAppleStandTime",
|
|
187
|
-
heartRate = "HKQuantityTypeIdentifierHeartRate",
|
|
188
|
-
bodyTemperature = "HKQuantityTypeIdentifierBodyTemperature",
|
|
189
|
-
basalBodyTemperature = "HKQuantityTypeIdentifierBasalBodyTemperature",
|
|
190
|
-
bloodPressureSystolic = "HKQuantityTypeIdentifierBloodPressureSystolic",
|
|
191
|
-
bloodPressureDiastolic = "HKQuantityTypeIdentifierBloodPressureDiastolic",
|
|
192
|
-
respiratoryRate = "HKQuantityTypeIdentifierRespiratoryRate",
|
|
193
|
-
restingHeartRate = "HKQuantityTypeIdentifierRestingHeartRate",
|
|
194
|
-
walkingHeartRateAverage = "HKQuantityTypeIdentifierWalkingHeartRateAverage",
|
|
195
|
-
heartRateVariabilitySDNN = "HKQuantityTypeIdentifierHeartRateVariabilitySDNN",
|
|
196
|
-
oxygenSaturation = "HKQuantityTypeIdentifierOxygenSaturation",
|
|
197
|
-
peripheralPerfusionIndex = "HKQuantityTypeIdentifierPeripheralPerfusionIndex",
|
|
198
|
-
bloodGlucose = "HKQuantityTypeIdentifierBloodGlucose",
|
|
199
|
-
numberOfTimesFallen = "HKQuantityTypeIdentifierNumberOfTimesFallen",
|
|
200
|
-
electrodermalActivity = "HKQuantityTypeIdentifierElectrodermalActivity",
|
|
201
|
-
inhalerUsage = "HKQuantityTypeIdentifierInhalerUsage",
|
|
202
|
-
insulinDelivery = "HKQuantityTypeIdentifierInsulinDelivery",
|
|
203
|
-
bloodAlcoholContent = "HKQuantityTypeIdentifierBloodAlcoholContent",
|
|
204
|
-
forcedVitalCapacity = "HKQuantityTypeIdentifierForcedVitalCapacity",
|
|
205
|
-
forcedExpiratoryVolume1 = "HKQuantityTypeIdentifierForcedExpiratoryVolume1",
|
|
206
|
-
peakExpiratoryFlowRate = "HKQuantityTypeIdentifierPeakExpiratoryFlowRate",
|
|
207
|
-
environmentalAudioExposure = "HKQuantityTypeIdentifierEnvironmentalAudioExposure",
|
|
208
|
-
headphoneAudioExposure = "HKQuantityTypeIdentifierHeadphoneAudioExposure",
|
|
209
|
-
dietaryFatTotal = "HKQuantityTypeIdentifierDietaryFatTotal",
|
|
210
|
-
dietaryFatPolyunsaturated = "HKQuantityTypeIdentifierDietaryFatPolyunsaturated",
|
|
211
|
-
dietaryFatMonounsaturated = "HKQuantityTypeIdentifierDietaryFatMonounsaturated",
|
|
212
|
-
dietaryFatSaturated = "HKQuantityTypeIdentifierDietaryFatSaturated",
|
|
213
|
-
dietaryCholesterol = "HKQuantityTypeIdentifierDietaryCholesterol",
|
|
214
|
-
dietarySodium = "HKQuantityTypeIdentifierDietarySodium",
|
|
215
|
-
dietaryCarbohydrates = "HKQuantityTypeIdentifierDietaryCarbohydrates",
|
|
216
|
-
dietaryFiber = "HKQuantityTypeIdentifierDietaryFiber",
|
|
217
|
-
dietarySugar = "HKQuantityTypeIdentifierDietarySugar",
|
|
218
|
-
dietaryEnergyConsumed = "HKQuantityTypeIdentifierDietaryEnergyConsumed",
|
|
219
|
-
dietaryProtein = "HKQuantityTypeIdentifierDietaryProtein",
|
|
220
|
-
dietaryVitaminA = "HKQuantityTypeIdentifierDietaryVitaminA",
|
|
221
|
-
dietaryVitaminB6 = "HKQuantityTypeIdentifierDietaryVitaminB6",
|
|
222
|
-
dietaryVitaminB12 = "HKQuantityTypeIdentifierDietaryVitaminB12",
|
|
223
|
-
dietaryVitaminC = "HKQuantityTypeIdentifierDietaryVitaminC",
|
|
224
|
-
dietaryVitaminD = "HKQuantityTypeIdentifierDietaryVitaminD",
|
|
225
|
-
dietaryVitaminE = "HKQuantityTypeIdentifierDietaryVitaminE",
|
|
226
|
-
dietaryVitaminK = "HKQuantityTypeIdentifierDietaryVitaminK",
|
|
227
|
-
dietaryCalcium = "HKQuantityTypeIdentifierDietaryCalcium",
|
|
228
|
-
dietaryIron = "HKQuantityTypeIdentifierDietaryIron",
|
|
229
|
-
dietaryThiamin = "HKQuantityTypeIdentifierDietaryThiamin",
|
|
230
|
-
dietaryRiboflavin = "HKQuantityTypeIdentifierDietaryRiboflavin",
|
|
231
|
-
dietaryNiacin = "HKQuantityTypeIdentifierDietaryNiacin",
|
|
232
|
-
dietaryFolate = "HKQuantityTypeIdentifierDietaryFolate",
|
|
233
|
-
dietaryBiotin = "HKQuantityTypeIdentifierDietaryBiotin",
|
|
234
|
-
dietaryPantothenicAcid = "HKQuantityTypeIdentifierDietaryPantothenicAcid",
|
|
235
|
-
dietaryPhosphorus = "HKQuantityTypeIdentifierDietaryPhosphorus",
|
|
236
|
-
dietaryIodine = "HKQuantityTypeIdentifierDietaryIodine",
|
|
237
|
-
dietaryMagnesium = "HKQuantityTypeIdentifierDietaryMagnesium",
|
|
238
|
-
dietaryZinc = "HKQuantityTypeIdentifierDietaryZinc",
|
|
239
|
-
dietarySelenium = "HKQuantityTypeIdentifierDietarySelenium",
|
|
240
|
-
dietaryCopper = "HKQuantityTypeIdentifierDietaryCopper",
|
|
241
|
-
dietaryManganese = "HKQuantityTypeIdentifierDietaryManganese",
|
|
242
|
-
dietaryChromium = "HKQuantityTypeIdentifierDietaryChromium",
|
|
243
|
-
dietaryMolybdenum = "HKQuantityTypeIdentifierDietaryMolybdenum",
|
|
244
|
-
dietaryChloride = "HKQuantityTypeIdentifierDietaryChloride",
|
|
245
|
-
dietaryPotassium = "HKQuantityTypeIdentifierDietaryPotassium",
|
|
246
|
-
dietaryCaffeine = "HKQuantityTypeIdentifierDietaryCaffeine",
|
|
247
|
-
dietaryWater = "HKQuantityTypeIdentifierDietaryWater",
|
|
248
|
-
sixMinuteWalkTestDistance = "HKQuantityTypeIdentifierSixMinuteWalkTestDistance",
|
|
249
|
-
walkingSpeed = "HKQuantityTypeIdentifierWalkingSpeed",
|
|
250
|
-
walkingStepLength = "HKQuantityTypeIdentifierWalkingStepLength",
|
|
251
|
-
walkingAsymmetryPercentage = "HKQuantityTypeIdentifierWalkingAsymmetryPercentage",
|
|
252
|
-
walkingDoubleSupportPercentage = "HKQuantityTypeIdentifierWalkingDoubleSupportPercentage",
|
|
253
|
-
stairAscentSpeed = "HKQuantityTypeIdentifierStairAscentSpeed",
|
|
254
|
-
stairDescentSpeed = "HKQuantityTypeIdentifierStairDescentSpeed",
|
|
255
|
-
uvExposure = "HKQuantityTypeIdentifierUvExposure"
|
|
266
|
+
readonly HKAverageMETs?: HKQuantity<HKUnit>;
|
|
267
|
+
readonly HKElevationAscended?: HKQuantity<HKUnit.Meters>;
|
|
268
|
+
readonly HKIndoorWorkout?: HKIndoorWorkout;
|
|
256
269
|
}
|
|
257
270
|
export declare enum HKAuthorizationRequestStatus {
|
|
258
271
|
unknown = 0,
|
|
@@ -455,9 +468,9 @@ export declare enum HKUnit {
|
|
|
455
468
|
}
|
|
456
469
|
export declare type HKDevice = {
|
|
457
470
|
readonly name: string;
|
|
458
|
-
readonly firmwareVersion: string;
|
|
471
|
+
readonly firmwareVersion: string | null;
|
|
459
472
|
readonly hardwareVersion: string;
|
|
460
|
-
readonly localIdentifier: string;
|
|
473
|
+
readonly localIdentifier: string | null;
|
|
461
474
|
readonly manufacturer: string;
|
|
462
475
|
readonly model: string;
|
|
463
476
|
readonly softwareVersion: string;
|
|
@@ -528,10 +541,6 @@ export declare type HKCorrelationRaw<TIdentifier extends HKCorrelationTypeIdenti
|
|
|
528
541
|
readonly endDate: string;
|
|
529
542
|
};
|
|
530
543
|
declare type QueryId = string;
|
|
531
|
-
export declare enum HKCorrelationTypeIdentifier {
|
|
532
|
-
bloodPressure = "HKCorrelationTypeIdentifierBloodPressure",
|
|
533
|
-
food = "HKCorrelationTypeIdentifierFood"
|
|
534
|
-
}
|
|
535
544
|
export declare enum HKUpdateFrequency {
|
|
536
545
|
immediate = 1,
|
|
537
546
|
hourly = 2,
|
|
@@ -553,7 +562,6 @@ export declare type WorkoutRoute = {
|
|
|
553
562
|
readonly HKMetadataKeySyncIdentifier?: string;
|
|
554
563
|
readonly HKMetadataKeySyncVersion?: number;
|
|
555
564
|
};
|
|
556
|
-
declare type AuthorizationStatusFor = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier;
|
|
557
565
|
declare type ReactNativeHealthkitTypeNative = {
|
|
558
566
|
isHealthDataAvailable(): Promise<boolean>;
|
|
559
567
|
getBloodType(): Promise<HKBloodType>;
|
|
@@ -569,7 +577,7 @@ declare type ReactNativeHealthkitTypeNative = {
|
|
|
569
577
|
readonly queryCorrelationSamples: <TIdentifier extends HKCorrelationTypeIdentifier>(typeIdentifier: TIdentifier, from: string, to: string) => Promise<readonly HKCorrelationRaw<TIdentifier>[]>;
|
|
570
578
|
subscribeToObserverQuery(identifier: HKSampleTypeIdentifier): Promise<QueryId>;
|
|
571
579
|
unsubscribeQuery(queryId: QueryId): Promise<boolean>;
|
|
572
|
-
authorizationStatusFor(type:
|
|
580
|
+
authorizationStatusFor(type: HealthkitReadAuthorization): Promise<boolean>;
|
|
573
581
|
getRequestStatusForAuthorization(write: WritePermissions, read: ReadPermissions): Promise<HKAuthorizationRequestStatus>;
|
|
574
582
|
requestAuthorization(write: WritePermissions, read: ReadPermissions): Promise<boolean>;
|
|
575
583
|
readonly saveQuantitySample: (identifier: HKQuantityTypeIdentifier, unit: HKUnit, value: number, start: string, end: string, metadata: unknown) => Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKCategorySampleRaw, HKCategoryTypeIdentifier, HKCategoryValueForIdentifier,
|
|
1
|
+
import type { HealthkitReadAuthorization, HealthkitWriteAuthorization, HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKCategorySampleRaw, HKCategoryTypeIdentifier, HKCategoryValueForIdentifier, HKCorrelationRaw, HKCorrelationTypeIdentifier, HKFitzpatrickSkinType, HKQuantitySampleRaw, HKQuantityTypeIdentifier, HKSampleTypeIdentifier, HKStatisticsOptions, HKUnit, HKUnitSI, HKUnitSIPrefix, HKUpdateFrequency, HKWheelchairUse, HKWorkoutActivityType, HKWorkoutMetadata, HKWorkoutRaw, MetadataMapperForCategoryIdentifier, MetadataMapperForCorrelationIdentifier, MetadataMapperForQuantityIdentifier, QueryStatisticsResponseRaw, WorkoutRoute } from './native-types';
|
|
2
2
|
export interface QueryWorkoutsOptions<TEnergy extends HKUnit, TDistance extends HKUnit> extends GenericQueryOptions {
|
|
3
3
|
readonly energyUnit?: TEnergy;
|
|
4
4
|
readonly distanceUnit?: TDistance;
|
|
@@ -36,10 +36,10 @@ export declare type GetWheelchairUseFn = () => Promise<HKWheelchairUse>;
|
|
|
36
36
|
export declare type GetFitzpatrickSkinTypeFn = () => Promise<HKFitzpatrickSkinType>;
|
|
37
37
|
export declare type QueryStatisticsForQuantityFn = <TUnit extends HKUnit>(identifier: HKQuantityTypeIdentifier, options: readonly HKStatisticsOptions[], from: Date, to?: Date, unit?: TUnit) => Promise<QueryStatisticsResponse<TUnit>>;
|
|
38
38
|
export declare type QueryWorkoutsFn = <TEnergy extends HKUnit, TDistance extends HKUnit>(options: QueryWorkoutsOptions<TEnergy, TDistance>) => Promise<readonly HKWorkout<TEnergy, TDistance>[]>;
|
|
39
|
-
export declare type AuthorizationStatusForFn = (type:
|
|
39
|
+
export declare type AuthorizationStatusForFn = (type: HealthkitReadAuthorization) => Promise<boolean>;
|
|
40
40
|
export declare type QueryCategorySamplesFn = <T extends HKCategoryTypeIdentifier>(identifier: T, options: GenericQueryOptions) => Promise<readonly HKCategorySample<T>[]>;
|
|
41
|
-
export declare type GetRequestStatusForAuthorizationFn = (read: readonly
|
|
42
|
-
export declare type RequestAuthorizationFn = (read: readonly
|
|
41
|
+
export declare type GetRequestStatusForAuthorizationFn = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => Promise<HKAuthorizationRequestStatus>;
|
|
42
|
+
export declare type RequestAuthorizationFn = (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => Promise<boolean>;
|
|
43
43
|
export declare type SaveQuantitySampleFn = <TUnit extends HKQuantityTypeIdentifier>(identifier: TUnit, unit: HKUnit, value: number, options?: {
|
|
44
44
|
readonly start?: Date;
|
|
45
45
|
readonly end?: Date;
|
|
@@ -57,7 +57,7 @@ export declare type SaveCategorySampleFn = <T extends HKCategoryTypeIdentifier>(
|
|
|
57
57
|
export declare type GetMostRecentCategorySampleFn = <T extends HKCategoryTypeIdentifier>(identifier: T) => Promise<HKCategorySample<T> | null>;
|
|
58
58
|
export declare type MostRecentCategorySampleHook = <T extends HKCategoryTypeIdentifier>(identifier: T) => HKCategorySample<T> | null;
|
|
59
59
|
export declare type MostRecentCorrelationSampleHook = <T extends HKCorrelationTypeIdentifier>(identifer: T) => HKCorrelation<T> | null;
|
|
60
|
-
export declare type GetMostRecentQuantitySampleFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends HKUnit>(identifier: TIdentifier, unit?: TUnit) => Promise<HKQuantitySample<TIdentifier, TUnit
|
|
60
|
+
export declare type GetMostRecentQuantitySampleFn = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends HKUnit>(identifier: TIdentifier, unit?: TUnit) => Promise<HKQuantitySample<TIdentifier, TUnit> | null>;
|
|
61
61
|
export declare type MostRecentQuantitySampleHook = <TIdentifier extends HKQuantityTypeIdentifier, TUnit extends HKUnit>(identifier: TIdentifier, unit?: TUnit) => HKQuantitySample<TIdentifier, TUnit> | null;
|
|
62
62
|
export declare type GetMostRecentWorkoutFn = <TEnergy extends HKUnit, TDistance extends HKUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => Promise<HKWorkout<TEnergy, TDistance> | null>;
|
|
63
63
|
export declare type MostRecentWorkoutHook = <TEnergy extends HKUnit, TDistance extends HKUnit>(options?: Pick<QueryWorkoutsOptions<TEnergy, TDistance>, 'distanceUnit' | 'energyUnit'>) => HKWorkout<TEnergy, TDistance> | null;
|
|
@@ -114,5 +114,7 @@ export declare type ReactNativeHealthkit = {
|
|
|
114
114
|
readonly useMostRecentCategorySample: MostRecentCategorySampleHook;
|
|
115
115
|
readonly useMostRecentQuantitySample: MostRecentQuantitySampleHook;
|
|
116
116
|
readonly useSubscribeToChanges: SubscribeToChangesHook;
|
|
117
|
+
readonly useIsHealthDataAvailable: () => boolean | null;
|
|
118
|
+
readonly useHealthkitAuthorization: (read: readonly HealthkitReadAuthorization[], write?: readonly HealthkitWriteAuthorization[]) => readonly [authorizationStatus: HKAuthorizationRequestStatus | null, request: () => Promise<HKAuthorizationRequestStatus | null>];
|
|
117
119
|
};
|
|
118
120
|
export {};
|
package/package.json
CHANGED
package/src/index.ios.tsx
CHANGED
|
@@ -4,23 +4,25 @@ import Native, {
|
|
|
4
4
|
EventEmitter,
|
|
5
5
|
HKQuantityTypeIdentifier,
|
|
6
6
|
HKUnit,
|
|
7
|
+
HKCategoryTypeIdentifier,
|
|
7
8
|
} from './native-types'
|
|
8
9
|
|
|
9
10
|
import type {
|
|
11
|
+
HealthkitReadAuthorization,
|
|
12
|
+
HealthkitWriteAuthorization,
|
|
13
|
+
HKAuthorizationRequestStatus,
|
|
10
14
|
HKCategorySampleRaw,
|
|
11
|
-
HKCategoryTypeIdentifier,
|
|
12
15
|
HKCategoryValueForIdentifier,
|
|
13
|
-
HKCharacteristicTypeIdentifier,
|
|
14
16
|
HKCorrelationRaw,
|
|
15
17
|
HKCorrelationTypeIdentifier,
|
|
16
18
|
HKQuantitySampleRaw,
|
|
17
|
-
HKSampleTypeIdentifier,
|
|
18
19
|
HKUnitSI,
|
|
19
20
|
HKUnitSIPrefix,
|
|
20
21
|
HKWorkoutRaw,
|
|
21
22
|
MetadataMapperForCategoryIdentifier,
|
|
22
23
|
ReadPermissions,
|
|
23
24
|
WritePermissions,
|
|
25
|
+
HKSampleTypeIdentifier,
|
|
24
26
|
} from './native-types'
|
|
25
27
|
import type {
|
|
26
28
|
GenericQueryOptions,
|
|
@@ -252,6 +254,8 @@ function useSubscribeToChanges<TIdentifier extends HKSampleTypeIdentifier>(
|
|
|
252
254
|
}, [identifier, onChange])
|
|
253
255
|
}
|
|
254
256
|
|
|
257
|
+
useSubscribeToChanges(HKCategoryTypeIdentifier.appleStandHour, () => {})
|
|
258
|
+
|
|
255
259
|
function useMostRecentCategorySample<
|
|
256
260
|
TCategory extends HKCategoryTypeIdentifier
|
|
257
261
|
>(identifier: TCategory) {
|
|
@@ -350,8 +354,8 @@ const queryStatisticsForQuantity: QueryStatisticsForQuantityFn = async (
|
|
|
350
354
|
}
|
|
351
355
|
|
|
352
356
|
const requestAuthorization = async (
|
|
353
|
-
read: readonly
|
|
354
|
-
write: readonly
|
|
357
|
+
read: readonly HealthkitReadAuthorization[],
|
|
358
|
+
write: readonly HealthkitWriteAuthorization[] = [],
|
|
355
359
|
): Promise<boolean> => {
|
|
356
360
|
const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)
|
|
357
361
|
|
|
@@ -366,8 +370,8 @@ const getDateOfBirth = async () => {
|
|
|
366
370
|
}
|
|
367
371
|
|
|
368
372
|
const getRequestStatusForAuthorization = async (
|
|
369
|
-
read: readonly
|
|
370
|
-
write: readonly
|
|
373
|
+
read: readonly HealthkitReadAuthorization[],
|
|
374
|
+
write: readonly HealthkitWriteAuthorization[] = [],
|
|
371
375
|
) => {
|
|
372
376
|
const readPermissions = read.reduce((obj, cur) => ({ ...obj, [cur]: true }), {} as ReadPermissions)
|
|
373
377
|
|
|
@@ -578,6 +582,37 @@ const Healthkit: ReactNativeHealthkit = {
|
|
|
578
582
|
useMostRecentWorkout,
|
|
579
583
|
|
|
580
584
|
useSubscribeToChanges,
|
|
585
|
+
|
|
586
|
+
useIsHealthDataAvailable: () => {
|
|
587
|
+
const [isAvailable, setIsAvailable] = useState<boolean | null>(null)
|
|
588
|
+
useEffect(() => {
|
|
589
|
+
const init = async () => {
|
|
590
|
+
const res = await Native.isHealthDataAvailable()
|
|
591
|
+
setIsAvailable(res)
|
|
592
|
+
}
|
|
593
|
+
void init()
|
|
594
|
+
}, [])
|
|
595
|
+
return isAvailable
|
|
596
|
+
},
|
|
597
|
+
useHealthkitAuthorization: (read, write) => {
|
|
598
|
+
const [status, setStatus] = useState<HKAuthorizationRequestStatus | null>(null)
|
|
599
|
+
const refreshAuthStatus = useCallback(async () => {
|
|
600
|
+
const auth = await getRequestStatusForAuthorization(read, write)
|
|
601
|
+
setStatus(auth)
|
|
602
|
+
return auth
|
|
603
|
+
}, [])
|
|
604
|
+
|
|
605
|
+
const request = useCallback(async () => {
|
|
606
|
+
await requestAuthorization(read, write)
|
|
607
|
+
return refreshAuthStatus()
|
|
608
|
+
}, [])
|
|
609
|
+
|
|
610
|
+
useEffect(() => {
|
|
611
|
+
void refreshAuthStatus()
|
|
612
|
+
}, [])
|
|
613
|
+
|
|
614
|
+
return [status, request]
|
|
615
|
+
},
|
|
581
616
|
}
|
|
582
617
|
|
|
583
618
|
export * from './native-types'
|
package/src/index.tsx
CHANGED
|
@@ -1,49 +1,66 @@
|
|
|
1
1
|
import { Platform } from 'react-native'
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
HKAuthorizationRequestStatus, HKBiologicalSex, HKBloodType, HKFitzpatrickSkinType, HKUnit, HKWheelchairUse,
|
|
5
|
+
} from './native-types'
|
|
6
|
+
|
|
3
7
|
import type { ReactNativeHealthkit } from './types'
|
|
4
8
|
|
|
5
|
-
const notAvailableError = `Platform "${
|
|
9
|
+
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${
|
|
6
10
|
Platform.OS
|
|
7
|
-
}" not supported
|
|
11
|
+
}" not supported`
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
function UnavailableFn<T = unknown>(retVal: T) {
|
|
14
|
+
return () => {
|
|
15
|
+
console.warn(notAvailableError)
|
|
16
|
+
return retVal
|
|
17
|
+
}
|
|
11
18
|
}
|
|
12
19
|
|
|
13
20
|
const Healthkit: ReactNativeHealthkit = {
|
|
14
|
-
authorizationStatusFor: UnavailableFn,
|
|
15
|
-
buildUnitWithPrefix: UnavailableFn,
|
|
16
|
-
disableAllBackgroundDelivery: UnavailableFn,
|
|
17
|
-
disableBackgroundDelivery: UnavailableFn,
|
|
18
|
-
enableBackgroundDelivery: UnavailableFn,
|
|
19
|
-
getBiologicalSex: UnavailableFn,
|
|
20
|
-
getBloodType: UnavailableFn,
|
|
21
|
-
getDateOfBirth: UnavailableFn,
|
|
22
|
-
getFitzpatrickSkinType: UnavailableFn,
|
|
23
|
-
getMostRecentCategorySample: UnavailableFn,
|
|
24
|
-
getMostRecentQuantitySample: UnavailableFn,
|
|
25
|
-
getMostRecentWorkout: UnavailableFn,
|
|
26
|
-
getPreferredUnit: UnavailableFn,
|
|
27
|
-
getPreferredUnits: UnavailableFn,
|
|
28
|
-
getRequestStatusForAuthorization: UnavailableFn,
|
|
29
|
-
getWheelchairUse: UnavailableFn,
|
|
30
|
-
getWorkoutRoutes: UnavailableFn,
|
|
21
|
+
authorizationStatusFor: UnavailableFn(Promise.resolve(false)),
|
|
22
|
+
buildUnitWithPrefix: UnavailableFn(HKUnit.Atmospheres),
|
|
23
|
+
disableAllBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
24
|
+
disableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
25
|
+
enableBackgroundDelivery: UnavailableFn(Promise.resolve(false)),
|
|
26
|
+
getBiologicalSex: UnavailableFn(Promise.resolve(HKBiologicalSex.notSet)),
|
|
27
|
+
getBloodType: UnavailableFn(Promise.resolve(HKBloodType.notSet)),
|
|
28
|
+
getDateOfBirth: UnavailableFn(Promise.resolve(new Date(0))),
|
|
29
|
+
getFitzpatrickSkinType: UnavailableFn(Promise.resolve(HKFitzpatrickSkinType.notSet)),
|
|
30
|
+
getMostRecentCategorySample: UnavailableFn(Promise.resolve(null)),
|
|
31
|
+
getMostRecentQuantitySample: UnavailableFn(Promise.resolve(null)),
|
|
32
|
+
getMostRecentWorkout: UnavailableFn(Promise.resolve(null)),
|
|
33
|
+
getPreferredUnit: UnavailableFn(Promise.resolve(HKUnit.Atmospheres)),
|
|
34
|
+
getPreferredUnits: UnavailableFn(Promise.resolve([])),
|
|
35
|
+
getRequestStatusForAuthorization: UnavailableFn(Promise.resolve(HKAuthorizationRequestStatus.unknown)),
|
|
36
|
+
getWheelchairUse: UnavailableFn(Promise.resolve(HKWheelchairUse.notSet)),
|
|
37
|
+
getWorkoutRoutes: UnavailableFn(Promise.resolve([])),
|
|
31
38
|
isHealthDataAvailable: async () => Promise.resolve(false),
|
|
32
|
-
queryCategorySamples: UnavailableFn,
|
|
33
|
-
queryCorrelationSamples: UnavailableFn,
|
|
34
|
-
queryQuantitySamples: UnavailableFn,
|
|
35
|
-
queryStatisticsForQuantity: UnavailableFn
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
queryCategorySamples: UnavailableFn(Promise.resolve([])),
|
|
40
|
+
queryCorrelationSamples: UnavailableFn(Promise.resolve([])),
|
|
41
|
+
queryQuantitySamples: UnavailableFn(Promise.resolve([])),
|
|
42
|
+
queryStatisticsForQuantity: UnavailableFn(Promise.resolve({
|
|
43
|
+
averageQuantity: undefined,
|
|
44
|
+
maximumQuantity: undefined,
|
|
45
|
+
minimumQuantity: undefined,
|
|
46
|
+
sumQuantity: undefined,
|
|
47
|
+
mostRecentQuantity: undefined,
|
|
48
|
+
mostRecentQuantityDateInterval: undefined,
|
|
49
|
+
duration: undefined,
|
|
50
|
+
})),
|
|
51
|
+
queryWorkouts: UnavailableFn(Promise.resolve([])),
|
|
52
|
+
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
53
|
+
saveCategorySample: UnavailableFn(Promise.resolve(false)),
|
|
54
|
+
saveCorrelationSample: UnavailableFn(Promise.resolve(false)),
|
|
55
|
+
saveQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
56
|
+
saveWorkoutSample: UnavailableFn(Promise.resolve(false)),
|
|
57
|
+
subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
|
|
58
|
+
useMostRecentCategorySample: UnavailableFn(null),
|
|
59
|
+
useMostRecentQuantitySample: UnavailableFn(null),
|
|
60
|
+
useMostRecentWorkout: UnavailableFn(null),
|
|
61
|
+
useSubscribeToChanges: UnavailableFn([null, () => null]),
|
|
62
|
+
useHealthkitAuthorization: UnavailableFn([null, async () => Promise.resolve(null)] as const),
|
|
63
|
+
useIsHealthDataAvailable: UnavailableFn(false),
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
export * from './native-types'
|