@kingstinct/react-native-healthkit 7.3.2 → 8.0.0
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 +1 -1
- package/ios/Constants.swift +1 -1
- package/ios/ReactNativeHealthkit.m +1 -1
- package/ios/ReactNativeHealthkit.swift +2 -2
- package/ios/Serializers.swift +12 -0
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +2 -3
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +42 -19
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +1 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +2 -3
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +17 -8
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +2 -3
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +4 -3
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +2 -3
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/hooks/useSources.js +2 -3
- package/lib/commonjs/hooks/useSources.js.map +1 -1
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +2 -3
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +1 -1
- package/lib/commonjs/hooks/useSubscribeToChanges.js +2 -3
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +1 -1
- package/lib/commonjs/index.ios.js +18 -43
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +3 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.native.js +46 -95
- package/lib/commonjs/index.native.js.map +1 -1
- package/lib/commonjs/index.web.js +3 -4
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/native-types.js +65 -90
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/test-setup.js +51 -0
- package/lib/commonjs/test-setup.js.map +1 -0
- package/lib/commonjs/test-utils.js +1 -2
- package/lib/commonjs/test-utils.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/deleteQuantitySample.js +2 -3
- package/lib/commonjs/utils/deleteQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/deleteSamples.js +2 -3
- package/lib/commonjs/utils/deleteSamples.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +1 -2
- package/lib/commonjs/utils/deserializeCategorySample.js.map +1 -1
- package/lib/commonjs/utils/deserializeCategorySample.test.js +8 -4
- package/lib/commonjs/utils/deserializeCategorySample.test.js.map +1 -1
- package/lib/commonjs/utils/deserializeCorrelation.js +2 -3
- package/lib/commonjs/utils/deserializeCorrelation.js.map +1 -1
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +1 -2
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
- package/lib/commonjs/utils/deserializeSample.js +1 -2
- package/lib/commonjs/utils/deserializeSample.js.map +1 -1
- package/lib/commonjs/utils/deserializeWorkout.js +1 -2
- package/lib/commonjs/utils/deserializeWorkout.js.map +1 -1
- package/lib/commonjs/utils/ensureMetadata.js +1 -2
- package/lib/commonjs/utils/ensureMetadata.js.map +1 -1
- package/lib/commonjs/utils/ensureTotals.js +1 -2
- package/lib/commonjs/utils/ensureTotals.js.map +1 -1
- package/lib/commonjs/utils/ensureUnit.js +2 -3
- package/lib/commonjs/utils/ensureUnit.js.map +1 -1
- package/lib/commonjs/utils/getDateOfBirth.js +2 -3
- package/lib/commonjs/utils/getDateOfBirth.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +2 -3
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +2 -3
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/getMostRecentWorkout.js +2 -3
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnit.js +2 -3
- package/lib/commonjs/utils/getPreferredUnit.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnits.js +2 -3
- package/lib/commonjs/utils/getPreferredUnits.js.map +1 -1
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +3 -4
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +1 -1
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +3 -5
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +1 -1
- package/lib/commonjs/utils/getWorkoutPlanById.js +2 -3
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -1
- package/lib/commonjs/utils/prepareOptions.js +3 -3
- package/lib/commonjs/utils/prepareOptions.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamples.js +2 -3
- package/lib/commonjs/utils/queryCategorySamples.js.map +1 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +2 -3
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +1 -1
- package/lib/commonjs/utils/queryCorrelationSamples.js +2 -3
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +1 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +2 -3
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +1 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +2 -3
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +2 -3
- package/lib/commonjs/utils/queryQuantitySamples.js.map +1 -1
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +2 -3
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +1 -1
- package/lib/commonjs/utils/querySources.js +2 -3
- package/lib/commonjs/utils/querySources.js.map +1 -1
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +2 -3
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +1 -1
- package/lib/commonjs/utils/queryWorkouts.js +2 -3
- package/lib/commonjs/utils/queryWorkouts.js.map +1 -1
- package/lib/commonjs/utils/requestAuthorization.js +3 -5
- package/lib/commonjs/utils/requestAuthorization.js.map +1 -1
- package/lib/commonjs/utils/saveCategorySample.js +2 -3
- package/lib/commonjs/utils/saveCategorySample.js.map +1 -1
- package/lib/commonjs/utils/saveCorrelationSample.js +2 -3
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -1
- package/lib/commonjs/utils/saveQuantitySample.js +2 -3
- package/lib/commonjs/utils/saveQuantitySample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +2 -3
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +2 -3
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.js +1 -2
- package/lib/commonjs/utils/serializeDate.js.map +1 -1
- package/lib/commonjs/utils/serializeDate.test.js +1 -1
- package/lib/commonjs/utils/serializeDate.test.js.map +1 -1
- package/lib/commonjs/utils/subscribeToChanges.js +6 -8
- package/lib/commonjs/utils/subscribeToChanges.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.js.map +1 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js +26 -3
- package/lib/module/hooks/useHealthkitAuthorization.test.js.map +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +1 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js +9 -2
- package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +1 -1
- package/lib/module/hooks/useMostRecentCategorySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +2 -0
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +1 -1
- package/lib/module/hooks/useMostRecentWorkout.js.map +1 -1
- package/lib/module/hooks/useSources.js.map +1 -1
- package/lib/module/hooks/useStatisticsForQuantity.js.map +1 -1
- package/lib/module/hooks/useSubscribeToChanges.js.map +1 -1
- package/lib/module/index.ios.js +4 -15
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.native.js +1 -3
- package/lib/module/index.native.js.map +1 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/native-types.js +21 -2
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/test-setup.js +48 -0
- package/lib/module/test-setup.js.map +1 -0
- package/lib/module/test-utils.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/deleteQuantitySample.js.map +1 -1
- package/lib/module/utils/deleteSamples.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.js.map +1 -1
- package/lib/module/utils/deserializeCategorySample.test.js +4 -2
- package/lib/module/utils/deserializeCategorySample.test.js.map +1 -1
- package/lib/module/utils/deserializeCorrelation.js.map +1 -1
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +1 -1
- package/lib/module/utils/deserializeSample.js.map +1 -1
- package/lib/module/utils/deserializeWorkout.js.map +1 -1
- package/lib/module/utils/ensureMetadata.js.map +1 -1
- package/lib/module/utils/ensureTotals.js.map +1 -1
- package/lib/module/utils/ensureUnit.js.map +1 -1
- package/lib/module/utils/getDateOfBirth.js.map +1 -1
- package/lib/module/utils/getMostRecentCategorySample.js.map +1 -1
- package/lib/module/utils/getMostRecentQuantitySample.js.map +1 -1
- package/lib/module/utils/getMostRecentWorkout.js.map +1 -1
- package/lib/module/utils/getPreferredUnit.js.map +1 -1
- package/lib/module/utils/getPreferredUnits.js.map +1 -1
- package/lib/module/utils/getPreferredUnitsTyped.js.map +1 -1
- package/lib/module/utils/getRequestStatusForAuthorization.js +1 -2
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +1 -1
- package/lib/module/utils/getWorkoutPlanById.js.map +1 -1
- package/lib/module/utils/prepareOptions.js +1 -0
- package/lib/module/utils/prepareOptions.js.map +1 -1
- package/lib/module/utils/queryCategorySamples.js.map +1 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +1 -1
- package/lib/module/utils/queryCorrelationSamples.js.map +1 -1
- package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +1 -1
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +1 -1
- package/lib/module/utils/queryQuantitySamples.js.map +1 -1
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +1 -1
- package/lib/module/utils/querySources.js.map +1 -1
- package/lib/module/utils/queryStatisticsForQuantity.js.map +1 -1
- package/lib/module/utils/queryWorkouts.js.map +1 -1
- package/lib/module/utils/requestAuthorization.js +1 -2
- package/lib/module/utils/requestAuthorization.js.map +1 -1
- package/lib/module/utils/saveCategorySample.js.map +1 -1
- package/lib/module/utils/saveCorrelationSample.js.map +1 -1
- package/lib/module/utils/saveQuantitySample.js.map +1 -1
- package/lib/module/utils/saveWorkoutRoute.js.map +1 -1
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/utils/serializeDate.js.map +1 -1
- package/lib/module/utils/serializeDate.test.js.map +1 -1
- package/lib/module/utils/subscribeToChanges.js +3 -4
- package/lib/module/utils/subscribeToChanges.js.map +1 -1
- package/lib/typescript/src/index.ios.d.ts +2 -10
- package/lib/typescript/src/index.native.d.ts +2 -2
- package/lib/typescript/src/native-types.d.ts +86 -8
- package/package.json +16 -11
- package/src/hooks/useHealthkitAuthorization.test.ts +18 -4
- package/src/hooks/useIsHealthDataAvailable.test.ts +5 -2
- package/src/hooks/useIsHealthDataAvailable.ts +1 -1
- package/src/hooks/useMostRecentQuantitySample.ts +3 -0
- package/src/index.ios.tsx +2 -15
- package/src/index.native.tsx +0 -3
- package/src/native-types.ts +97 -9
- package/src/test-setup.ts +51 -0
- package/src/utils/deserializeCategorySample.test.ts +5 -2
- package/src/utils/prepareOptions.ts +1 -0
- package/lib/commonjs/jest.setup.js +0 -45
- package/lib/commonjs/jest.setup.js.map +0 -1
- package/lib/module/jest.setup.js +0 -43
- package/lib/module/jest.setup.js.map +0 -1
- package/src/jest.setup.ts +0 -46
- /package/lib/typescript/src/{jest.setup.d.ts → test-setup.d.ts} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import Native, { EventEmitter } from '../native-types';
|
|
2
2
|
const subscribeToChanges = async (identifier, callback) => {
|
|
3
|
-
const subscription = EventEmitter.addListener('onChange',
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = _ref;
|
|
3
|
+
const subscription = EventEmitter.addListener('onChange', ({
|
|
4
|
+
typeIdentifier
|
|
5
|
+
}) => {
|
|
7
6
|
if (typeIdentifier === identifier) {
|
|
8
7
|
callback();
|
|
9
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Native","EventEmitter","subscribeToChanges","identifier","callback","subscription","addListener","
|
|
1
|
+
{"version":3,"names":["Native","EventEmitter","subscribeToChanges","identifier","callback","subscription","addListener","typeIdentifier","queryId","subscribeToObserverQuery","catch","error","remove","Promise","reject","unsubscribeQuery"],"sources":["subscribeToChanges.ts"],"sourcesContent":["import Native, { EventEmitter } from '../native-types'\n\nimport type { HKSampleTypeIdentifier } from '..'\n\nconst subscribeToChanges = async (\n identifier: HKSampleTypeIdentifier,\n callback: () => void,\n) => {\n const subscription = EventEmitter.addListener(\n 'onChange',\n ({ typeIdentifier }) => {\n if (typeIdentifier === identifier) {\n callback()\n }\n },\n )\n\n const queryId = await Native.subscribeToObserverQuery(identifier).catch(\n async (error) => {\n subscription.remove()\n return Promise.reject(error)\n },\n )\n\n return async () => {\n subscription.remove()\n return Native.unsubscribeQuery(queryId)\n }\n}\n\nexport default subscribeToChanges\n"],"mappings":"AAAA,OAAOA,MAAM,IAAIC,YAAY,QAAQ,iBAAiB;AAItD,MAAMC,kBAAkB,GAAG,MAAAA,CACzBC,UAAkC,EAClCC,QAAoB,KACjB;EACH,MAAMC,YAAY,GAAGJ,YAAY,CAACK,WAAW,CAC3C,UAAU,EACV,CAAC;IAAEC;EAAe,CAAC,KAAK;IACtB,IAAIA,cAAc,KAAKJ,UAAU,EAAE;MACjCC,QAAQ,CAAC,CAAC;IACZ;EACF,CACF,CAAC;EAED,MAAMI,OAAO,GAAG,MAAMR,MAAM,CAACS,wBAAwB,CAACN,UAAU,CAAC,CAACO,KAAK,CACrE,MAAOC,KAAK,IAAK;IACfN,YAAY,CAACO,MAAM,CAAC,CAAC;IACrB,OAAOC,OAAO,CAACC,MAAM,CAACH,KAAK,CAAC;EAC9B,CACF,CAAC;EAED,OAAO,YAAY;IACjBN,YAAY,CAACO,MAAM,CAAC,CAAC;IACrB,OAAOZ,MAAM,CAACe,gBAAgB,CAACP,OAAO,CAAC;EACzC,CAAC;AACH,CAAC;AAED,eAAeN,kBAAkB","ignoreList":[]}
|
|
@@ -37,7 +37,7 @@ import subscribeToChanges from './utils/subscribeToChanges';
|
|
|
37
37
|
declare const availableQuantityTypes: (majorVersionIOS?: number) => HKQuantityTypeIdentifier[];
|
|
38
38
|
declare const authorizationStatusFor: (type: import("./native-types").HealthkitReadAuthorization) => Promise<import("./native-types").HKAuthorizationStatus>;
|
|
39
39
|
declare const isHealthDataAvailable: () => Promise<boolean>;
|
|
40
|
-
declare const
|
|
40
|
+
declare const isProtectedDataAvailable: () => Promise<boolean>;
|
|
41
41
|
declare const disableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier) => Promise<boolean>;
|
|
42
42
|
declare const disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
43
43
|
declare const enableBackgroundDelivery: (typeIdentifier: import("./native-types").HKSampleTypeIdentifier, updateFrequency: import("./native-types").HKUpdateFrequency) => Promise<boolean>;
|
|
@@ -72,13 +72,6 @@ declare const _default: {
|
|
|
72
72
|
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
73
73
|
*/
|
|
74
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
|
-
*/
|
|
81
|
-
canAccessProtectedData: () => Promise<boolean>;
|
|
82
75
|
/**
|
|
83
76
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}
|
|
84
77
|
*/
|
|
@@ -175,6 +168,5 @@ declare const _default: {
|
|
|
175
168
|
useStatisticsForQuantity: typeof useStatisticsForQuantity;
|
|
176
169
|
};
|
|
177
170
|
export default _default;
|
|
178
|
-
|
|
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, };
|
|
171
|
+
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, isProtectedDataAvailable, };
|
|
180
172
|
export * from './types';
|
|
@@ -22,8 +22,8 @@ declare const authorizationStatusFor: () => Promise<HKAuthorizationStatus>, avai
|
|
|
22
22
|
mostRecentQuantity: undefined;
|
|
23
23
|
mostRecentQuantityDateInterval: undefined;
|
|
24
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,
|
|
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, isProtectedDataAvailable: () => Promise<boolean>;
|
|
26
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,
|
|
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, isProtectedDataAvailable, };
|
|
28
28
|
export * from './types';
|
|
29
29
|
export default Healthkit;
|
|
@@ -623,7 +623,61 @@ export declare enum HKQuantityTypeIdentifier {
|
|
|
623
623
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifierrunningspeed Apple Docs HKQuantityTypeIdentifierRunningSpeed}
|
|
624
624
|
* @since iOS 16
|
|
625
625
|
*/
|
|
626
|
-
runningSpeed = "HKQuantityTypeIdentifierRunningSpeed"
|
|
626
|
+
runningSpeed = "HKQuantityTypeIdentifierRunningSpeed",
|
|
627
|
+
/**
|
|
628
|
+
* Cross Country Skiing Speed
|
|
629
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierCrossCountrySkiingSpeed Apple Docs HKQuantityTypeIdentifierCrossCountrySkiingSpeed}
|
|
630
|
+
* @since iOS 18
|
|
631
|
+
*/
|
|
632
|
+
crossCountrySkiingSpeed = "HKQuantityTypeIdentifierCrossCountrySkiingSpeed",
|
|
633
|
+
/**
|
|
634
|
+
* Cross Country Skiing Distance
|
|
635
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierDistanceCrossCountrySkiing Apple Docs HKQuantityTypeIdentifierCrossCountrySkiingDistance}
|
|
636
|
+
* @since iOS 18
|
|
637
|
+
*/
|
|
638
|
+
distanceCrossCountrySkiing = "HKQuantityTypeIdentifierDistanceCrossCountrySkiing",
|
|
639
|
+
/**
|
|
640
|
+
* Paddle Sports Distance
|
|
641
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierDistancePaddleSports Apple Docs HKQuantityTypeIdentifierDistancePaddleSports}
|
|
642
|
+
* @since iOS 18
|
|
643
|
+
*/
|
|
644
|
+
distancePaddleSports = "HKQuantityTypeIdentifierDistancePaddleSports",
|
|
645
|
+
/**
|
|
646
|
+
* Rowing Distance
|
|
647
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierDistanceRowing Apple Docs HKQuantityTypeIdentifierDistanceRowing}
|
|
648
|
+
* @since iOS 18
|
|
649
|
+
*/
|
|
650
|
+
distanceRowing = "HKQuantityTypeIdentifierDistanceRowing",
|
|
651
|
+
/**
|
|
652
|
+
* Skating Sports Distance
|
|
653
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierDistanceSkatingSports Apple Docs HKQuantityTypeIdentifierDistanceSkatingSports}
|
|
654
|
+
* @since iOS 18
|
|
655
|
+
*/
|
|
656
|
+
distanceSkatingSports = "HKQuantityTypeIdentifierDistanceSkatingSports",
|
|
657
|
+
/**
|
|
658
|
+
* Estimated Workout Effort Score
|
|
659
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierEstimatedWorkoutEffortScore Apple Docs HKQuantityTypeIdentifierEstimatedWorkoutEffortScore}
|
|
660
|
+
* @since iOS 18
|
|
661
|
+
*/
|
|
662
|
+
estimatedWorkoutEffortScore = "HKQuantityTypeIdentifierEstimatedWorkoutEffortScore",
|
|
663
|
+
/**
|
|
664
|
+
* Paddle Sports Speed
|
|
665
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierPaddleSportsSpeed Apple Docs HKQuantityTypeIdentifierPaddleSportsSpeed}
|
|
666
|
+
* @since iOS 18
|
|
667
|
+
*/
|
|
668
|
+
paddleSportsSpeed = "HKQuantityTypeIdentifierPaddleSportsSpeed",
|
|
669
|
+
/**
|
|
670
|
+
* Rowing Speed
|
|
671
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierRowingSpeed Apple Docs HKQuantityTypeIdentifierRowingSpeed}
|
|
672
|
+
* @since iOS 18
|
|
673
|
+
*/
|
|
674
|
+
rowingSpeed = "HKQuantityTypeIdentifierRowingSpeed",
|
|
675
|
+
/**
|
|
676
|
+
* Workout Effort Score
|
|
677
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKQuantityTypeIdentifierWorkoutEffortScore Apple Docs HKQuantityTypeIdentifierWorkoutEffortScore}
|
|
678
|
+
* @since iOS 18
|
|
679
|
+
*/
|
|
680
|
+
workoutEffortScore = "HKQuantityTypeIdentifierWorkoutEffortScore"
|
|
627
681
|
}
|
|
628
682
|
export type TypeToUnitMapping = {
|
|
629
683
|
readonly [key in HKQuantityTypeIdentifier]: HKUnit;
|
|
@@ -651,6 +705,10 @@ export declare enum HKCategoryTypeIdentifier {
|
|
|
651
705
|
appleStandHour = "HKCategoryTypeIdentifierAppleStandHour",
|
|
652
706
|
cervicalMucusQuality = "HKCategoryTypeIdentifierCervicalMucusQuality",
|
|
653
707
|
ovulationTestResult = "HKCategoryTypeIdentifierOvulationTestResult",
|
|
708
|
+
/**
|
|
709
|
+
* @deprecated In iOS 18 beta
|
|
710
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifiermenstrualflow Apple Docs }
|
|
711
|
+
*/
|
|
654
712
|
menstrualFlow = "HKCategoryTypeIdentifierMenstrualFlow",
|
|
655
713
|
intermenstrualBleeding = "HKCategoryTypeIdentifierIntermenstrualBleeding",
|
|
656
714
|
sexualActivity = "HKCategoryTypeIdentifierSexualActivity",
|
|
@@ -711,7 +769,19 @@ export declare enum HKCategoryTypeIdentifier {
|
|
|
711
769
|
soreThroat = "HKCategoryTypeIdentifierSoreThroat",
|
|
712
770
|
vaginalDryness = "HKCategoryTypeIdentifierVaginalDryness",
|
|
713
771
|
vomiting = "HKCategoryTypeIdentifierVomiting",
|
|
714
|
-
wheezing = "HKCategoryTypeIdentifierWheezing"
|
|
772
|
+
wheezing = "HKCategoryTypeIdentifierWheezing",
|
|
773
|
+
/**
|
|
774
|
+
* Bleeding After Pregnancy
|
|
775
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierbleedingafterpregnancy Apple Docs }
|
|
776
|
+
* @since iOS 18
|
|
777
|
+
*/
|
|
778
|
+
bleedingAfterPregnancy = "HKCategoryTypeIdentifierBleedingAfterPregnancy",
|
|
779
|
+
/**
|
|
780
|
+
* Bleeding During Pregnancy
|
|
781
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategorytypeidentifierbleedingduringpregnancy Apple Docs }
|
|
782
|
+
* @since iOS 18
|
|
783
|
+
*/
|
|
784
|
+
bleedingDuringPregnancy = "HKCategoryTypeIdentifierBleedingDuringPregnancy"
|
|
715
785
|
}
|
|
716
786
|
export type HKSampleTypeIdentifier = HKCategoryTypeIdentifier | HKCorrelationTypeIdentifier | HKQuantityTypeIdentifier | typeof HKActivitySummaryTypeIdentifier | typeof HKAudiogramTypeIdentifier | typeof HKDataTypeIdentifierHeartbeatSeries | typeof HKWorkoutRouteTypeIdentifier | typeof HKWorkoutTypeIdentifier | `${HKCategoryTypeIdentifier}` | `${HKCorrelationTypeIdentifier}` | `${HKQuantityTypeIdentifier}`;
|
|
717
787
|
export type HealthkitReadAuthorization = HKCharacteristicTypeIdentifier | HKSampleTypeIdentifier | `${HKCharacteristicTypeIdentifier}` | `${HKSampleTypeIdentifier}`;
|
|
@@ -797,6 +867,13 @@ export declare enum HKWorkoutActivityType {
|
|
|
797
867
|
handCycling = 74,
|
|
798
868
|
discSports = 75,
|
|
799
869
|
fitnessGaming = 76,
|
|
870
|
+
cardioDance = 77,
|
|
871
|
+
socialDance = 78,
|
|
872
|
+
pickleball = 79,
|
|
873
|
+
cooldown = 80,
|
|
874
|
+
swimBikeRun = 82,
|
|
875
|
+
transition = 83,
|
|
876
|
+
underwaterDiving = 84,
|
|
800
877
|
other = 3000
|
|
801
878
|
}
|
|
802
879
|
export type HKGenericMetadata = {
|
|
@@ -949,6 +1026,7 @@ export declare enum HKCategoryValueCervicalMucusQuality {
|
|
|
949
1026
|
}
|
|
950
1027
|
/**
|
|
951
1028
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvaluemenstrualflow Apple Docs }
|
|
1029
|
+
* @deprecated In iOS 18 beta
|
|
952
1030
|
*/
|
|
953
1031
|
export declare enum HKCategoryValueMenstrualFlow {
|
|
954
1032
|
unspecified = 1,
|
|
@@ -978,7 +1056,7 @@ export declare enum HKCategoryValueSleepAnalysis {
|
|
|
978
1056
|
asleepREM = 5
|
|
979
1057
|
}
|
|
980
1058
|
/**
|
|
981
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvalueappetitechanges
|
|
1059
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvalueappetitechanges Apple Docs}
|
|
982
1060
|
*/
|
|
983
1061
|
export declare enum HKCategoryValueAppetiteChanges {
|
|
984
1062
|
decreased = 2,
|
|
@@ -987,7 +1065,7 @@ export declare enum HKCategoryValueAppetiteChanges {
|
|
|
987
1065
|
unspecified = 0
|
|
988
1066
|
}
|
|
989
1067
|
/**
|
|
990
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvaluepresence
|
|
1068
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvaluepresence Apple Docs}
|
|
991
1069
|
*/
|
|
992
1070
|
export declare enum HKCategoryValuePresence {
|
|
993
1071
|
notPresent = 1,
|
|
@@ -1030,8 +1108,8 @@ export type MetadataMapperForQuantityIdentifier<TQuantityTypeIdentifier = HKQuan
|
|
|
1030
1108
|
export type MetadataMapperForCorrelationIdentifier<TCorrelationTypeIdentifier = HKCorrelationTypeIdentifier> = TCorrelationTypeIdentifier extends HKCorrelationTypeIdentifier.food ? HKGenericMetadata & {
|
|
1031
1109
|
readonly HKFoodType?: string;
|
|
1032
1110
|
} : HKGenericMetadata;
|
|
1033
|
-
export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> = T extends HKQuantityTypeIdentifier.bloodGlucose ? BloodGlucoseUnit : T extends HKQuantityTypeIdentifier.appleExerciseTime | HKQuantityTypeIdentifier.appleMoveTime | HKQuantityTypeIdentifier.appleStandTime ? TimeUnit : T extends HKQuantityTypeIdentifier.activeEnergyBurned | HKQuantityTypeIdentifier.basalEnergyBurned | HKQuantityTypeIdentifier.dietaryEnergyConsumed ? EnergyUnit : T extends HKQuantityTypeIdentifier.distanceCycling | HKQuantityTypeIdentifier.distanceDownhillSnowSports | HKQuantityTypeIdentifier.distanceSwimming | HKQuantityTypeIdentifier.distanceWalkingRunning | HKQuantityTypeIdentifier.distanceWheelchair | HKQuantityTypeIdentifier.sixMinuteWalkTestDistance | HKQuantityTypeIdentifier.waistCircumference ? LengthUnit : T extends HKQuantityTypeIdentifier.bodyFatPercentage | HKQuantityTypeIdentifier.oxygenSaturation | HKQuantityTypeIdentifier.walkingAsymmetryPercentage | HKQuantityTypeIdentifier.walkingDoubleSupportPercentage ? HKUnits.Percent : T extends HKQuantityTypeIdentifier.basalBodyTemperature
|
|
1034
|
-
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> = T extends HKCategoryTypeIdentifier.cervicalMucusQuality ? HKCategoryValueCervicalMucusQuality : T extends HKCategoryTypeIdentifier.menstrualFlow ? HKCategoryValueMenstrualFlow : T extends HKCategoryTypeIdentifier.ovulationTestResult ? HKCategoryValueOvulationTestResult : T extends HKCategoryTypeIdentifier.sleepAnalysis ? HKCategoryValueSleepAnalysis : T extends HKCategoryTypeIdentifier.highHeartRateEvent | HKCategoryTypeIdentifier.intermenstrualBleeding | HKCategoryTypeIdentifier.mindfulSession | HKCategoryTypeIdentifier.sexualActivity ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.abdominalCramps | HKCategoryTypeIdentifier.
|
|
1111
|
+
export type UnitForIdentifier<T extends HKQuantityTypeIdentifier> = T extends HKQuantityTypeIdentifier.bloodGlucose ? BloodGlucoseUnit : T extends HKQuantityTypeIdentifier.appleExerciseTime | HKQuantityTypeIdentifier.appleMoveTime | HKQuantityTypeIdentifier.appleStandTime ? TimeUnit : T extends HKQuantityTypeIdentifier.activeEnergyBurned | HKQuantityTypeIdentifier.basalEnergyBurned | HKQuantityTypeIdentifier.dietaryEnergyConsumed ? EnergyUnit : T extends HKQuantityTypeIdentifier.distanceCycling | HKQuantityTypeIdentifier.distanceDownhillSnowSports | HKQuantityTypeIdentifier.distanceSwimming | HKQuantityTypeIdentifier.distanceWalkingRunning | HKQuantityTypeIdentifier.distanceWheelchair | HKQuantityTypeIdentifier.sixMinuteWalkTestDistance | HKQuantityTypeIdentifier.waistCircumference ? LengthUnit : T extends HKQuantityTypeIdentifier.bodyFatPercentage | HKQuantityTypeIdentifier.oxygenSaturation | HKQuantityTypeIdentifier.walkingAsymmetryPercentage | HKQuantityTypeIdentifier.walkingDoubleSupportPercentage ? HKUnits.Percent : T extends HKQuantityTypeIdentifier.basalBodyTemperature ? TemperatureUnit : T extends HKQuantityTypeIdentifier.runningSpeed | HKQuantityTypeIdentifier.stairAscentSpeed | HKQuantityTypeIdentifier.stairDescentSpeed | HKQuantityTypeIdentifier.walkingSpeed ? SpeedUnit<LengthUnit, TimeUnit> : T extends HKQuantityTypeIdentifier.flightsClimbed | HKQuantityTypeIdentifier.numberOfAlcoholicBeverages | HKQuantityTypeIdentifier.numberOfTimesFallen | HKQuantityTypeIdentifier.pushCount | HKQuantityTypeIdentifier.stepCount | HKQuantityTypeIdentifier.swimmingStrokeCount ? HKUnits.Count : T extends HKQuantityTypeIdentifier.dietaryBiotin | HKQuantityTypeIdentifier.dietaryCaffeine | HKQuantityTypeIdentifier.dietaryCalcium | HKQuantityTypeIdentifier.dietaryCarbohydrates | HKQuantityTypeIdentifier.dietaryChloride | HKQuantityTypeIdentifier.dietaryCholesterol | HKQuantityTypeIdentifier.dietaryChromium | HKQuantityTypeIdentifier.dietaryCopper | HKQuantityTypeIdentifier.dietaryFatMonounsaturated | HKQuantityTypeIdentifier.dietaryFatPolyunsaturated | HKQuantityTypeIdentifier.dietaryFatSaturated | HKQuantityTypeIdentifier.dietaryFatTotal | HKQuantityTypeIdentifier.dietaryFiber | HKQuantityTypeIdentifier.dietaryFolate | HKQuantityTypeIdentifier.dietaryIodine | HKQuantityTypeIdentifier.dietaryIron | HKQuantityTypeIdentifier.dietaryMagnesium | HKQuantityTypeIdentifier.dietaryManganese | HKQuantityTypeIdentifier.dietaryMolybdenum | HKQuantityTypeIdentifier.dietaryNiacin | HKQuantityTypeIdentifier.dietaryPantothenicAcid | HKQuantityTypeIdentifier.dietaryPhosphorus | HKQuantityTypeIdentifier.dietaryPotassium | HKQuantityTypeIdentifier.dietaryProtein | HKQuantityTypeIdentifier.dietaryRiboflavin | HKQuantityTypeIdentifier.dietarySelenium | HKQuantityTypeIdentifier.dietarySodium | HKQuantityTypeIdentifier.dietarySugar | HKQuantityTypeIdentifier.dietaryThiamin | HKQuantityTypeIdentifier.dietaryVitaminA | HKQuantityTypeIdentifier.dietaryVitaminB6 | HKQuantityTypeIdentifier.dietaryVitaminB12 | HKQuantityTypeIdentifier.dietaryVitaminC | HKQuantityTypeIdentifier.dietaryVitaminD | HKQuantityTypeIdentifier.dietaryVitaminE | HKQuantityTypeIdentifier.dietaryVitaminK | HKQuantityTypeIdentifier.dietaryZinc ? MassUnit : T extends HKQuantityTypeIdentifier.dietaryWater ? VolumeUnit : T extends HKQuantityTypeIdentifier.insulinDelivery ? HKUnits.InternationalUnit | `${HKUnits.InternationalUnit}` : T extends HKQuantityTypeIdentifier.heartRate | HKQuantityTypeIdentifier.restingHeartRate | HKQuantityTypeIdentifier.walkingHeartRateAverage ? CountPerTime<TimeUnit> : HKUnit;
|
|
1112
|
+
export type HKCategoryValueForIdentifier<T extends HKCategoryTypeIdentifier> = T extends HKCategoryTypeIdentifier.cervicalMucusQuality ? HKCategoryValueCervicalMucusQuality : T extends HKCategoryTypeIdentifier.menstrualFlow ? HKCategoryValueMenstrualFlow : T extends HKCategoryTypeIdentifier.ovulationTestResult ? HKCategoryValueOvulationTestResult : T extends HKCategoryTypeIdentifier.sleepAnalysis ? HKCategoryValueSleepAnalysis : T extends HKCategoryTypeIdentifier.highHeartRateEvent | HKCategoryTypeIdentifier.intermenstrualBleeding | HKCategoryTypeIdentifier.mindfulSession | HKCategoryTypeIdentifier.sexualActivity ? HKCategoryValueNotApplicable : T extends HKCategoryTypeIdentifier.abdominalCramps | HKCategoryTypeIdentifier.acne | HKCategoryTypeIdentifier.bladderIncontinence | HKCategoryTypeIdentifier.bloating | HKCategoryTypeIdentifier.breastPain | HKCategoryTypeIdentifier.chestTightnessOrPain | HKCategoryTypeIdentifier.chills | HKCategoryTypeIdentifier.constipation | HKCategoryTypeIdentifier.coughing | HKCategoryTypeIdentifier.diarrhea | HKCategoryTypeIdentifier.dizziness | HKCategoryTypeIdentifier.drySkin | HKCategoryTypeIdentifier.fainting | HKCategoryTypeIdentifier.fatigue | HKCategoryTypeIdentifier.fever | HKCategoryTypeIdentifier.generalizedBodyAche | HKCategoryTypeIdentifier.hairLoss | HKCategoryTypeIdentifier.headache | HKCategoryTypeIdentifier.heartburn | HKCategoryTypeIdentifier.hotFlashes | HKCategoryTypeIdentifier.lossOfSmell | HKCategoryTypeIdentifier.lossOfTaste | HKCategoryTypeIdentifier.lowerBackPain | HKCategoryTypeIdentifier.memoryLapse | HKCategoryTypeIdentifier.moodChanges | HKCategoryTypeIdentifier.nausea | HKCategoryTypeIdentifier.nightSweats | HKCategoryTypeIdentifier.pelvicPain | HKCategoryTypeIdentifier.rapidPoundingOrFlutteringHeartbeat | HKCategoryTypeIdentifier.runnyNose | HKCategoryTypeIdentifier.shortnessOfBreath | HKCategoryTypeIdentifier.sinusCongestion | HKCategoryTypeIdentifier.skippedHeartbeat | HKCategoryTypeIdentifier.soreThroat | HKCategoryTypeIdentifier.vaginalDryness | HKCategoryTypeIdentifier.vomiting | HKCategoryTypeIdentifier.wheezing ? HKCategoryValueSeverity : T extends HKCategoryTypeIdentifier.appetiteChanges | HKCategoryTypeIdentifier.sleepChanges ? HKCategoryValuePresence : T extends HKCategoryTypeIdentifier.lowCardioFitnessEvent ? HKCategoryValueLowCardioFitnessEvent : T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult : T extends HKCategoryTypeIdentifier.pregnancyTestResult ? HKCategoryValuePregnancyTestResult : T extends HKCategoryTypeIdentifier.appleStandHour ? HKCategoryValueAppleStandHour : number;
|
|
1035
1113
|
/**
|
|
1036
1114
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkcategoryvaluepregnancytestresult Apple Docs }
|
|
1037
1115
|
*/
|
|
@@ -1219,7 +1297,7 @@ export declare enum BloodGlucoseUnit {
|
|
|
1219
1297
|
}
|
|
1220
1298
|
export type SpeedUnit<TLength extends LengthUnit, TTime extends TimeUnit> = `${TLength}/${TTime}`;
|
|
1221
1299
|
export type CountPerTime<TTime extends TimeUnit> = `count/${TTime}`;
|
|
1222
|
-
export type HKUnit = BloodGlucoseUnit | CountPerTime<TimeUnit> | EnergyUnit | FrequencyUnit | HKUnits | LengthUnit | MassUnit | PressureUnit | SpeedUnit<LengthUnit, TimeUnit> | TemperatureUnit | TimeUnit | VolumeUnit | `${BloodGlucoseUnit}` | `${EnergyUnit}` | `${
|
|
1300
|
+
export type HKUnit = BloodGlucoseUnit | CountPerTime<TimeUnit> | EnergyUnit | FrequencyUnit | HKUnits | LengthUnit | MassUnit | PressureUnit | SpeedUnit<LengthUnit, TimeUnit> | TemperatureUnit | TimeUnit | VolumeUnit | `${BloodGlucoseUnit}` | `${EnergyUnit}` | `${HKUnits}` | `${LengthUnit}` | `${MassUnit}` | `${PressureUnit}` | `${TemperatureUnit}` | `${TimeUnit}` | `${VolumeUnit}`;
|
|
1223
1301
|
/**
|
|
1224
1302
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkdevice Apple Docs }
|
|
1225
1303
|
*/
|
|
@@ -1421,7 +1499,7 @@ type ReactNativeHealthkitTypeNative = {
|
|
|
1421
1499
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs }
|
|
1422
1500
|
*/
|
|
1423
1501
|
isHealthDataAvailable(): Promise<boolean>;
|
|
1424
|
-
|
|
1502
|
+
isProtectedDataAvailable(): Promise<boolean>;
|
|
1425
1503
|
getBloodType(): Promise<HKBloodType>;
|
|
1426
1504
|
getDateOfBirth(): Promise<string>;
|
|
1427
1505
|
getBiologicalSex(): Promise<HKBiologicalSex>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingstinct/react-native-healthkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "React Native bindings for HealthKit",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"app.plugin.js"
|
|
21
21
|
],
|
|
22
22
|
"scripts": {
|
|
23
|
-
"test-only": "
|
|
24
|
-
"test": "concurrently \"
|
|
23
|
+
"test-only": "bun test --preload ./src/test-setup.ts src",
|
|
24
|
+
"test": "concurrently \"bun test-only\" \"bun typecheck\" \"bun lint\"",
|
|
25
25
|
"typecheck": "tsc --noEmit",
|
|
26
26
|
"lint": "eslint \"**/*.{js,ts,tsx}\" --cache",
|
|
27
27
|
"prepare": "bob build && husky install",
|
|
28
28
|
"release": "release-it",
|
|
29
|
-
"example": "yarn --cwd example",
|
|
30
29
|
"pods": "cd example && pod-install --quiet",
|
|
31
|
-
"bootstrap": "
|
|
30
|
+
"bootstrap": "cd example && bun install && bun pods",
|
|
31
|
+
"upgrade-interactive": "bunx npm-check-updates --format group -i"
|
|
32
32
|
},
|
|
33
33
|
"lint-staged": {
|
|
34
34
|
"*.swift": "swiftlint ios --fix",
|
|
@@ -44,7 +44,15 @@
|
|
|
44
44
|
"react-hooks"
|
|
45
45
|
],
|
|
46
46
|
"repository": "https://github.com/kingstinct/react-native-healthkit",
|
|
47
|
-
"
|
|
47
|
+
"funding": [
|
|
48
|
+
"https://github.com/sponsors/kingstinct",
|
|
49
|
+
"https://github.com/sponsors/robertherber"
|
|
50
|
+
],
|
|
51
|
+
"author": {
|
|
52
|
+
"name": "Robert Herber",
|
|
53
|
+
"email": "robert@kingstinct.com",
|
|
54
|
+
"url": "https://github.com/robertherber"
|
|
55
|
+
},
|
|
48
56
|
"license": "MIT",
|
|
49
57
|
"bugs": {
|
|
50
58
|
"url": "https://github.com/kingstinct/react-native-healthkit/issues"
|
|
@@ -58,14 +66,14 @@
|
|
|
58
66
|
"@graphql-eslint/eslint-plugin": ">=3",
|
|
59
67
|
"@release-it/conventional-changelog": "2",
|
|
60
68
|
"@testing-library/react-native": "12",
|
|
61
|
-
"@types/
|
|
69
|
+
"@types/bun": "^1.1.3",
|
|
62
70
|
"@types/node": "^18.7.14",
|
|
63
71
|
"@types/react": "~18.0.27",
|
|
64
72
|
"@typescript-eslint/eslint-plugin": ">=5",
|
|
65
73
|
"@typescript-eslint/parser": ">=5",
|
|
66
74
|
"commitlint": "^17.1.1",
|
|
67
75
|
"concurrently": "8",
|
|
68
|
-
"eslint": "
|
|
76
|
+
"eslint": "8",
|
|
69
77
|
"eslint-config-airbnb": ">=19",
|
|
70
78
|
"eslint-config-airbnb-base": ">=15",
|
|
71
79
|
"eslint-config-kingstinct": "^5.1.1",
|
|
@@ -85,8 +93,6 @@
|
|
|
85
93
|
"expo": ">=45",
|
|
86
94
|
"graphql": ">=16",
|
|
87
95
|
"husky": "8",
|
|
88
|
-
"jest": ">=26",
|
|
89
|
-
"jest-environment-jsdom": "^29.0.2",
|
|
90
96
|
"lint-staged": "^13.2.2",
|
|
91
97
|
"metro-react-native-babel-preset": "^0.70.3",
|
|
92
98
|
"pod-install": "^0.1.0",
|
|
@@ -97,7 +103,6 @@
|
|
|
97
103
|
"release-it": "14",
|
|
98
104
|
"solidarity": "^3.0.4",
|
|
99
105
|
"solidarity-react-native": "^2.1.2",
|
|
100
|
-
"ts-node": "^10.9.1",
|
|
101
106
|
"typescript": "^4.9.4"
|
|
102
107
|
},
|
|
103
108
|
"peerDependencies": {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { renderHook, act } from '@testing-library/react-native'
|
|
2
2
|
|
|
3
|
-
import useHealthkitAuthorization from './useHealthkitAuthorization'
|
|
4
|
-
import Native, { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier } from '../native-types'
|
|
5
3
|
import waitForNextUpdate from '../test-utils'
|
|
6
4
|
|
|
7
5
|
describe('useHealthkitAuthorization', () => {
|
|
6
|
+
let NativeTypes: typeof import('../native-types')
|
|
7
|
+
let useHealthkitAuthorization: typeof import('./useHealthkitAuthorization').default
|
|
8
|
+
beforeAll(async () => {
|
|
9
|
+
NativeTypes = await import('../native-types')
|
|
10
|
+
useHealthkitAuthorization = (await import('./useHealthkitAuthorization')).default
|
|
11
|
+
})
|
|
12
|
+
|
|
8
13
|
test('should return shouldRequest', async () => {
|
|
14
|
+
const { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier, default: Native } = NativeTypes
|
|
15
|
+
|
|
9
16
|
jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.shouldRequest))
|
|
10
17
|
|
|
11
18
|
const { result } = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]))
|
|
@@ -16,6 +23,8 @@ describe('useHealthkitAuthorization', () => {
|
|
|
16
23
|
})
|
|
17
24
|
|
|
18
25
|
test('should request permissions', async () => {
|
|
26
|
+
const { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier, default: Native } = NativeTypes
|
|
27
|
+
|
|
19
28
|
const spy = jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.shouldRequest))
|
|
20
29
|
jest.spyOn(Native, 'requestAuthorization').mockReturnValue(Promise.resolve(true))
|
|
21
30
|
|
|
@@ -25,9 +34,10 @@ describe('useHealthkitAuthorization', () => {
|
|
|
25
34
|
|
|
26
35
|
spy.mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.unnecessary))
|
|
27
36
|
|
|
28
|
-
let retVal: HKAuthorizationRequestStatus | undefined
|
|
37
|
+
let retVal: typeof HKAuthorizationRequestStatus | undefined
|
|
29
38
|
await act(async () => {
|
|
30
|
-
|
|
39
|
+
const r = await result.current[1]() as unknown as typeof HKAuthorizationRequestStatus
|
|
40
|
+
retVal = r
|
|
31
41
|
})
|
|
32
42
|
|
|
33
43
|
expect(result.current[0]).toBe(HKAuthorizationRequestStatus.unnecessary)
|
|
@@ -35,6 +45,8 @@ describe('useHealthkitAuthorization', () => {
|
|
|
35
45
|
})
|
|
36
46
|
|
|
37
47
|
test('should return unnecessary', async () => {
|
|
48
|
+
const { HKAuthorizationRequestStatus, HKCategoryTypeIdentifier, default: Native } = NativeTypes
|
|
49
|
+
|
|
38
50
|
jest.spyOn(Native, 'getRequestStatusForAuthorization').mockReturnValue(Promise.resolve(HKAuthorizationRequestStatus.unnecessary))
|
|
39
51
|
|
|
40
52
|
const { result } = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]))
|
|
@@ -45,6 +57,8 @@ describe('useHealthkitAuthorization', () => {
|
|
|
45
57
|
})
|
|
46
58
|
|
|
47
59
|
test('should return null before initalizing', async () => {
|
|
60
|
+
const { HKCategoryTypeIdentifier } = NativeTypes
|
|
61
|
+
|
|
48
62
|
const { result } = renderHook(() => useHealthkitAuthorization([HKCategoryTypeIdentifier.abdominalCramps]))
|
|
49
63
|
|
|
50
64
|
expect(result.current[0]).toBe(null)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react-native'
|
|
2
2
|
|
|
3
|
-
import useIsHealthDataAvailable from './useIsHealthDataAvailable'
|
|
4
|
-
import Native from '../native-types'
|
|
5
3
|
import waitForNextUpdate from '../test-utils'
|
|
6
4
|
|
|
7
5
|
describe('useIsHealthDataAvailable', () => {
|
|
8
6
|
test('should return false', async () => {
|
|
7
|
+
const useIsHealthDataAvailable = (await import('./useIsHealthDataAvailable')).default
|
|
8
|
+
const { default: Native } = await import('../native-types')
|
|
9
9
|
jest.spyOn(Native, 'isHealthDataAvailable').mockReturnValue(Promise.resolve(false))
|
|
10
10
|
|
|
11
11
|
const { result } = renderHook(useIsHealthDataAvailable)
|
|
@@ -16,6 +16,8 @@ describe('useIsHealthDataAvailable', () => {
|
|
|
16
16
|
})
|
|
17
17
|
|
|
18
18
|
test('should return true', async () => {
|
|
19
|
+
const useIsHealthDataAvailable = (await import('./useIsHealthDataAvailable')).default
|
|
20
|
+
const { default: Native } = await import('../native-types')
|
|
19
21
|
jest.spyOn(Native, 'isHealthDataAvailable').mockReturnValue(Promise.resolve(true))
|
|
20
22
|
|
|
21
23
|
const { result } = renderHook(useIsHealthDataAvailable)
|
|
@@ -26,6 +28,7 @@ describe('useIsHealthDataAvailable', () => {
|
|
|
26
28
|
})
|
|
27
29
|
|
|
28
30
|
test('should return null before initalizing', async () => {
|
|
31
|
+
const useIsHealthDataAvailable = (await import('./useIsHealthDataAvailable')).default
|
|
29
32
|
const { result } = renderHook(useIsHealthDataAvailable)
|
|
30
33
|
|
|
31
34
|
expect(result.current).toBe(null)
|
|
@@ -7,7 +7,7 @@ import Native from '../native-types'
|
|
|
7
7
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple HealthKit isHealthDataAvailable}
|
|
8
8
|
* @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.
|
|
9
9
|
*/
|
|
10
|
-
const useIsHealthDataAvailable = () => {
|
|
10
|
+
const useIsHealthDataAvailable = (): boolean | null => {
|
|
11
11
|
const [isAvailable, setIsAvailable] = useState<boolean | null>(null)
|
|
12
12
|
|
|
13
13
|
useEffect(() => {
|
|
@@ -24,6 +24,9 @@ function useMostRecentQuantitySample<
|
|
|
24
24
|
const init = async () => {
|
|
25
25
|
const actualUnit = await ensureUnit(identifier, unit)
|
|
26
26
|
|
|
27
|
+
const value = await getMostRecentQuantitySample(identifier, actualUnit)
|
|
28
|
+
setLastSample(value)
|
|
29
|
+
|
|
27
30
|
cancelSubscription = await subscribeToChanges(identifier, async () => {
|
|
28
31
|
const value = await getMostRecentQuantitySample(identifier, actualUnit)
|
|
29
32
|
setLastSample(value)
|
package/src/index.ios.tsx
CHANGED
|
@@ -59,8 +59,7 @@ const availableQuantityTypes = (majorVersionIOS = currentMajorVersionIOS) => {
|
|
|
59
59
|
|
|
60
60
|
const authorizationStatusFor = Native.authorizationStatusFor.bind(Native)
|
|
61
61
|
const isHealthDataAvailable = Native.isHealthDataAvailable.bind(Native)
|
|
62
|
-
|
|
63
|
-
const canAccessProtectedData = Native.canAccessProtectedData.bind(Native)
|
|
62
|
+
const isProtectedDataAvailable = Native.isProtectedDataAvailable.bind(Native)
|
|
64
63
|
const disableBackgroundDelivery = Native.disableBackgroundDelivery.bind(Native)
|
|
65
64
|
const disableAllBackgroundDelivery = Native.disableAllBackgroundDelivery.bind(Native)
|
|
66
65
|
const enableBackgroundDelivery = Native.enableBackgroundDelivery.bind(Native)
|
|
@@ -98,16 +97,7 @@ export default {
|
|
|
98
97
|
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
99
98
|
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
100
99
|
*/
|
|
101
|
-
isProtectedDataAvailable
|
|
102
|
-
|
|
103
|
-
// Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)
|
|
104
|
-
/**
|
|
105
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}
|
|
106
|
-
* @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}
|
|
107
|
-
* @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.
|
|
108
|
-
* @returns {boolean} A Boolean value that indicates whether content protection is active.
|
|
109
|
-
*/
|
|
110
|
-
canAccessProtectedData,
|
|
100
|
+
isProtectedDataAvailable,
|
|
111
101
|
|
|
112
102
|
/**
|
|
113
103
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}
|
|
@@ -220,8 +210,6 @@ export default {
|
|
|
220
210
|
useStatisticsForQuantity,
|
|
221
211
|
}
|
|
222
212
|
|
|
223
|
-
const isProtectedDataAvailable = canAccessProtectedData
|
|
224
|
-
|
|
225
213
|
export {
|
|
226
214
|
authorizationStatusFor,
|
|
227
215
|
availableQuantityTypes,
|
|
@@ -269,7 +257,6 @@ export {
|
|
|
269
257
|
useIsHealthDataAvailable,
|
|
270
258
|
useSources,
|
|
271
259
|
useStatisticsForQuantity,
|
|
272
|
-
canAccessProtectedData,
|
|
273
260
|
isProtectedDataAvailable,
|
|
274
261
|
}
|
|
275
262
|
|
package/src/index.native.tsx
CHANGED
|
@@ -91,7 +91,6 @@ const authorizationStatusFor = UnavailableFn(Promise.resolve(HKAuthorizationStat
|
|
|
91
91
|
useSubscribeToChanges = UnavailableFn([null, () => null]),
|
|
92
92
|
useHealthkitAuthorization = UnavailableFn([null, async () => Promise.resolve(HKAuthorizationRequestStatus.unknown)] as const),
|
|
93
93
|
useIsHealthDataAvailable = () => false,
|
|
94
|
-
canAccessProtectedData = async () => Promise.resolve(false),
|
|
95
94
|
isProtectedDataAvailable = async () => Promise.resolve(false)
|
|
96
95
|
|
|
97
96
|
const Healthkit: typeof ReactNativeHealthkit = {
|
|
@@ -141,7 +140,6 @@ const Healthkit: typeof ReactNativeHealthkit = {
|
|
|
141
140
|
useSubscribeToChanges,
|
|
142
141
|
useHealthkitAuthorization,
|
|
143
142
|
useIsHealthDataAvailable,
|
|
144
|
-
canAccessProtectedData,
|
|
145
143
|
isProtectedDataAvailable,
|
|
146
144
|
}
|
|
147
145
|
|
|
@@ -192,7 +190,6 @@ export {
|
|
|
192
190
|
useSubscribeToChanges,
|
|
193
191
|
useHealthkitAuthorization,
|
|
194
192
|
useIsHealthDataAvailable,
|
|
195
|
-
canAccessProtectedData,
|
|
196
193
|
isProtectedDataAvailable,
|
|
197
194
|
}
|
|
198
195
|
|