@kingstinct/react-native-healthkit 8.7.2 → 9.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/ReactNativeHealthkit.podspec +36 -0
- package/app.plugin.js +43 -33
- package/ios/Bridge.h +8 -0
- package/ios/CategoryTypeModule.swift +128 -0
- package/ios/CharacteristicTypeModule.swift +78 -0
- package/ios/Constants.swift +2 -0
- package/ios/CoreModule.swift +376 -0
- package/ios/CorrelationTypeModule.swift +153 -0
- package/ios/HeartbeatSeriesModule.swift +189 -0
- package/ios/Helpers.swift +529 -251
- package/ios/QuantityTypeModule.swift +461 -0
- package/ios/Serializers.swift +211 -124
- package/ios/SourceProxy.swift +35 -0
- package/ios/StateOfMindModule.swift +160 -0
- package/ios/WorkoutProxy.swift +405 -0
- package/ios/WorkoutSessionModule.swift +182 -0
- package/ios/WorkoutsModule.swift +357 -0
- package/package.json +43 -127
- package/react-native.config.js +16 -0
- package/src/hooks/useHealthkitAuthorization.test.ts +47 -29
- package/src/hooks/useHealthkitAuthorization.ts +21 -15
- package/src/hooks/useIsHealthDataAvailable.test.ts +17 -7
- package/src/hooks/useIsHealthDataAvailable.ts +7 -7
- package/src/hooks/useMostRecentCategorySample.ts +10 -12
- package/src/hooks/useMostRecentQuantitySample.ts +17 -36
- package/src/hooks/useMostRecentWorkout.ts +16 -38
- package/src/hooks/useSources.ts +8 -12
- package/src/hooks/useStatisticsForQuantity.ts +19 -14
- package/src/hooks/useSubscribeToChanges.ts +9 -13
- package/src/index.ios.ts +232 -0
- package/src/index.ts +444 -0
- package/src/modules.ts +43 -0
- package/src/specs/CategoryTypeModule.nitro.ts +64 -0
- package/src/specs/CharacteristicTypeModule.nitro.ts +22 -0
- package/src/specs/CoreModule.nitro.ts +107 -0
- package/src/specs/CorrelationTypeModule.nitro.ts +23 -0
- package/src/specs/HeartbeatSeriesModule.nitro.ts +19 -0
- package/src/specs/QuantityTypeModule.nitro.ts +60 -0
- package/src/specs/SourceProxy.nitro.ts +13 -0
- package/src/specs/StateOfMindModule.nitro.ts +23 -0
- package/src/specs/WorkoutProxy.nitro.ts +18 -0
- package/src/specs/WorkoutSessionModule.nitro.ts +71 -0
- package/src/specs/WorkoutsModule.nitro.ts +32 -0
- package/src/test-setup.ts +68 -54
- package/src/test-utils.ts +3 -2
- package/src/types/Auth.ts +17 -0
- package/src/types/Background.ts +9 -0
- package/src/types/CategoryType.ts +249 -0
- package/src/types/CategoryTypeIdentifier.ts +99 -0
- package/src/types/Characteristics.ts +53 -0
- package/src/types/Constants.ts +25 -0
- package/src/types/CorrelationType.ts +31 -0
- package/src/types/Device.ts +13 -0
- package/src/types/HeartbeatSeries.ts +29 -0
- package/src/types/InterfaceVerification.ts +164 -0
- package/src/types/InterfaceVerificationExample.ts +89 -0
- package/src/types/QuantitySample.ts +30 -0
- package/src/types/QuantityType.ts +192 -0
- package/src/types/QuantityTypeIdentifier.ts +758 -0
- package/src/types/QueryOptions.ts +69 -0
- package/src/types/README-InterfaceVerification.md +103 -0
- package/src/types/Shared.ts +79 -0
- package/src/types/Source.ts +11 -0
- package/src/types/StateOfMind.ts +110 -0
- package/src/types/Subscriptons.ts +10 -0
- package/src/types/Units.ts +190 -0
- package/src/types/WeatherCondition.ts +31 -0
- package/src/types/WorkoutKit.ts +18 -0
- package/src/types/Workouts.ts +282 -0
- package/src/utils/getMostRecentCategorySample.ts +7 -11
- package/src/utils/getMostRecentQuantitySample.ts +8 -18
- package/src/utils/getMostRecentWorkout.ts +7 -17
- package/src/utils/getPreferredUnit.ts +12 -8
- package/src/utils/subscribeToChanges.ts +9 -26
- package/LICENSE +0 -21
- package/README.md +0 -179
- package/ios/ReactNativeHealthkit-Bridging-Header.h +0 -2
- package/ios/ReactNativeHealthkit.m +0 -271
- package/ios/ReactNativeHealthkit.swift +0 -2333
- package/ios/ReactNativeHealthkit.xcodeproj/project.pbxproj +0 -279
- package/kingstinct-react-native-healthkit.podspec +0 -21
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +0 -39
- package/lib/commonjs/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js +0 -72
- package/lib/commonjs/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js +0 -27
- package/lib/commonjs/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js +0 -41
- package/lib/commonjs/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentCategorySample.js +0 -23
- package/lib/commonjs/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js +0 -37
- package/lib/commonjs/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/hooks/useMostRecentWorkout.js +0 -48
- package/lib/commonjs/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/hooks/useSources.js +0 -22
- package/lib/commonjs/hooks/useSources.js.map +0 -1
- package/lib/commonjs/hooks/useStatisticsForQuantity.js +0 -28
- package/lib/commonjs/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/hooks/useSubscribeToChanges.js +0 -28
- package/lib/commonjs/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/commonjs/index.ios.js +0 -531
- package/lib/commonjs/index.ios.js.map +0 -1
- package/lib/commonjs/index.js +0 -22
- package/lib/commonjs/index.js.map +0 -1
- package/lib/commonjs/index.native.js +0 -235
- package/lib/commonjs/index.native.js.map +0 -1
- package/lib/commonjs/index.web.js +0 -22
- package/lib/commonjs/index.web.js.map +0 -1
- package/lib/commonjs/native-types.js +0 -1575
- package/lib/commonjs/native-types.js.map +0 -1
- package/lib/commonjs/test-setup.js +0 -57
- package/lib/commonjs/test-setup.js.map +0 -1
- package/lib/commonjs/test-utils.js +0 -18
- package/lib/commonjs/test-utils.js.map +0 -1
- package/lib/commonjs/types.js +0 -17
- package/lib/commonjs/types.js.map +0 -1
- package/lib/commonjs/utils/deleteQuantitySample.js +0 -11
- package/lib/commonjs/utils/deleteQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/deleteSamples.js +0 -18
- package/lib/commonjs/utils/deleteSamples.js.map +0 -1
- package/lib/commonjs/utils/deleteWorkoutSample.js +0 -11
- package/lib/commonjs/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.js +0 -13
- package/lib/commonjs/utils/deserializeCategorySample.js.map +0 -1
- package/lib/commonjs/utils/deserializeCategorySample.test.js +0 -26
- package/lib/commonjs/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/commonjs/utils/deserializeCorrelation.js +0 -26
- package/lib/commonjs/utils/deserializeCorrelation.js.map +0 -1
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js +0 -15
- package/lib/commonjs/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeSample.js +0 -15
- package/lib/commonjs/utils/deserializeSample.js.map +0 -1
- package/lib/commonjs/utils/deserializeWorkout.js +0 -15
- package/lib/commonjs/utils/deserializeWorkout.js.map +0 -1
- package/lib/commonjs/utils/ensureMetadata.js +0 -11
- package/lib/commonjs/utils/ensureMetadata.js.map +0 -1
- package/lib/commonjs/utils/ensureTotals.js +0 -11
- package/lib/commonjs/utils/ensureTotals.js.map +0 -1
- package/lib/commonjs/utils/ensureUnit.js +0 -17
- package/lib/commonjs/utils/ensureUnit.js.map +0 -1
- package/lib/commonjs/utils/getDateOfBirth.js +0 -14
- package/lib/commonjs/utils/getDateOfBirth.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentCategorySample.js +0 -17
- package/lib/commonjs/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentQuantitySample.js +0 -21
- package/lib/commonjs/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/getMostRecentWorkout.js +0 -19
- package/lib/commonjs/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnit.js +0 -14
- package/lib/commonjs/utils/getPreferredUnit.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnits.js +0 -14
- package/lib/commonjs/utils/getPreferredUnits.js.map +0 -1
- package/lib/commonjs/utils/getPreferredUnitsTyped.js +0 -33
- package/lib/commonjs/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js +0 -21
- package/lib/commonjs/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/commonjs/utils/getWorkoutPlanById.js +0 -13
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/commonjs/utils/prepareOptions.js +0 -25
- package/lib/commonjs/utils/prepareOptions.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamples.js +0 -17
- package/lib/commonjs/utils/queryCategorySamples.js.map +0 -1
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryCorrelationSamples.js +0 -17
- package/lib/commonjs/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js +0 -17
- package/lib/commonjs/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -21
- package/lib/commonjs/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamples.js +0 -19
- package/lib/commonjs/utils/queryQuantitySamples.js.map +0 -1
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js +0 -23
- package/lib/commonjs/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/querySources.js +0 -14
- package/lib/commonjs/utils/querySources.js.map +0 -1
- package/lib/commonjs/utils/queryStateOfMindSamples.js +0 -22
- package/lib/commonjs/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js +0 -16
- package/lib/commonjs/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryStatisticsForQuantity.js +0 -29
- package/lib/commonjs/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js +0 -26
- package/lib/commonjs/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/commonjs/utils/queryWorkouts.js +0 -22
- package/lib/commonjs/utils/queryWorkouts.js.map +0 -1
- package/lib/commonjs/utils/requestAuthorization.js +0 -22
- package/lib/commonjs/utils/requestAuthorization.js.map +0 -1
- package/lib/commonjs/utils/saveCategorySample.js +0 -20
- package/lib/commonjs/utils/saveCategorySample.js.map +0 -1
- package/lib/commonjs/utils/saveCorrelationSample.js +0 -35
- package/lib/commonjs/utils/saveCorrelationSample.js.map +0 -1
- package/lib/commonjs/utils/saveQuantitySample.js +0 -16
- package/lib/commonjs/utils/saveQuantitySample.js.map +0 -1
- package/lib/commonjs/utils/saveStateOfMindSample.js +0 -17
- package/lib/commonjs/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +0 -26
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/commonjs/utils/saveWorkoutSample.js +0 -36
- package/lib/commonjs/utils/saveWorkoutSample.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.js +0 -9
- package/lib/commonjs/utils/serializeDate.js.map +0 -1
- package/lib/commonjs/utils/serializeDate.test.js +0 -17
- package/lib/commonjs/utils/serializeDate.test.js.map +0 -1
- package/lib/commonjs/utils/startWatchApp.js +0 -11
- package/lib/commonjs/utils/startWatchApp.js.map +0 -1
- package/lib/commonjs/utils/subscribeToChanges.js +0 -27
- package/lib/commonjs/utils/subscribeToChanges.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.js +0 -32
- package/lib/module/hooks/useHealthkitAuthorization.js.map +0 -1
- package/lib/module/hooks/useHealthkitAuthorization.test.js +0 -68
- package/lib/module/hooks/useHealthkitAuthorization.test.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.js +0 -21
- package/lib/module/hooks/useIsHealthDataAvailable.js.map +0 -1
- package/lib/module/hooks/useIsHealthDataAvailable.test.js +0 -37
- package/lib/module/hooks/useIsHealthDataAvailable.test.js.map +0 -1
- package/lib/module/hooks/useMostRecentCategorySample.js +0 -16
- package/lib/module/hooks/useMostRecentCategorySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentQuantitySample.js +0 -30
- package/lib/module/hooks/useMostRecentQuantitySample.js.map +0 -1
- package/lib/module/hooks/useMostRecentWorkout.js +0 -41
- package/lib/module/hooks/useMostRecentWorkout.js.map +0 -1
- package/lib/module/hooks/useSources.js +0 -15
- package/lib/module/hooks/useSources.js.map +0 -1
- package/lib/module/hooks/useStatisticsForQuantity.js +0 -21
- package/lib/module/hooks/useStatisticsForQuantity.js.map +0 -1
- package/lib/module/hooks/useSubscribeToChanges.js +0 -21
- package/lib/module/hooks/useSubscribeToChanges.js.map +0 -1
- package/lib/module/index.ios.js +0 -209
- package/lib/module/index.ios.js.map +0 -1
- package/lib/module/index.js +0 -4
- package/lib/module/index.js.map +0 -1
- package/lib/module/index.native.js +0 -160
- package/lib/module/index.native.js.map +0 -1
- package/lib/module/index.web.js +0 -4
- package/lib/module/index.web.js.map +0 -1
- package/lib/module/native-types.js +0 -1606
- package/lib/module/native-types.js.map +0 -1
- package/lib/module/test-setup.js +0 -54
- package/lib/module/test-setup.js.map +0 -1
- package/lib/module/test-utils.js +0 -11
- package/lib/module/test-utils.js.map +0 -1
- package/lib/module/types.js +0 -67
- package/lib/module/types.js.map +0 -1
- package/lib/module/utils/deleteQuantitySample.js +0 -4
- package/lib/module/utils/deleteQuantitySample.js.map +0 -1
- package/lib/module/utils/deleteSamples.js +0 -11
- package/lib/module/utils/deleteSamples.js.map +0 -1
- package/lib/module/utils/deleteWorkoutSample.js +0 -4
- package/lib/module/utils/deleteWorkoutSample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.js +0 -7
- package/lib/module/utils/deserializeCategorySample.js.map +0 -1
- package/lib/module/utils/deserializeCategorySample.test.js +0 -22
- package/lib/module/utils/deserializeCategorySample.test.js.map +0 -1
- package/lib/module/utils/deserializeCorrelation.js +0 -19
- package/lib/module/utils/deserializeCorrelation.js.map +0 -1
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js +0 -9
- package/lib/module/utils/deserializeHeartbeatSeriesSample.js.map +0 -1
- package/lib/module/utils/deserializeSample.js +0 -9
- package/lib/module/utils/deserializeSample.js.map +0 -1
- package/lib/module/utils/deserializeWorkout.js +0 -9
- package/lib/module/utils/deserializeWorkout.js.map +0 -1
- package/lib/module/utils/ensureMetadata.js +0 -5
- package/lib/module/utils/ensureMetadata.js.map +0 -1
- package/lib/module/utils/ensureTotals.js +0 -5
- package/lib/module/utils/ensureTotals.js.map +0 -1
- package/lib/module/utils/ensureUnit.js +0 -10
- package/lib/module/utils/ensureUnit.js.map +0 -1
- package/lib/module/utils/getDateOfBirth.js +0 -7
- package/lib/module/utils/getDateOfBirth.js.map +0 -1
- package/lib/module/utils/getMostRecentCategorySample.js +0 -10
- package/lib/module/utils/getMostRecentCategorySample.js.map +0 -1
- package/lib/module/utils/getMostRecentQuantitySample.js +0 -14
- package/lib/module/utils/getMostRecentQuantitySample.js.map +0 -1
- package/lib/module/utils/getMostRecentWorkout.js +0 -12
- package/lib/module/utils/getMostRecentWorkout.js.map +0 -1
- package/lib/module/utils/getPreferredUnit.js +0 -7
- package/lib/module/utils/getPreferredUnit.js.map +0 -1
- package/lib/module/utils/getPreferredUnits.js +0 -7
- package/lib/module/utils/getPreferredUnits.js.map +0 -1
- package/lib/module/utils/getPreferredUnitsTyped.js +0 -26
- package/lib/module/utils/getPreferredUnitsTyped.js.map +0 -1
- package/lib/module/utils/getRequestStatusForAuthorization.js +0 -14
- package/lib/module/utils/getRequestStatusForAuthorization.js.map +0 -1
- package/lib/module/utils/getWorkoutPlanById.js +0 -6
- package/lib/module/utils/getWorkoutPlanById.js.map +0 -1
- package/lib/module/utils/prepareOptions.js +0 -18
- package/lib/module/utils/prepareOptions.js.map +0 -1
- package/lib/module/utils/queryCategorySamples.js +0 -10
- package/lib/module/utils/queryCategorySamples.js.map +0 -1
- package/lib/module/utils/queryCategorySamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryCategorySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryCorrelationSamples.js +0 -10
- package/lib/module/utils/queryCorrelationSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamples.js +0 -10
- package/lib/module/utils/queryHeartbeatSeriesSamples.js.map +0 -1
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js +0 -14
- package/lib/module/utils/queryHeartbeatSeriesSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryQuantitySamples.js +0 -12
- package/lib/module/utils/queryQuantitySamples.js.map +0 -1
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js +0 -16
- package/lib/module/utils/queryQuantitySamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/querySources.js +0 -7
- package/lib/module/utils/querySources.js.map +0 -1
- package/lib/module/utils/queryStateOfMindSamples.js +0 -14
- package/lib/module/utils/queryStateOfMindSamples.js.map +0 -1
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js +0 -9
- package/lib/module/utils/queryStatisticsCollectionForQuantity.js.map +0 -1
- package/lib/module/utils/queryStatisticsForQuantity.js +0 -22
- package/lib/module/utils/queryStatisticsForQuantity.js.map +0 -1
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js +0 -19
- package/lib/module/utils/queryWorkoutSamplesWithAnchor.js.map +0 -1
- package/lib/module/utils/queryWorkouts.js +0 -15
- package/lib/module/utils/queryWorkouts.js.map +0 -1
- package/lib/module/utils/requestAuthorization.js +0 -15
- package/lib/module/utils/requestAuthorization.js.map +0 -1
- package/lib/module/utils/saveCategorySample.js +0 -13
- package/lib/module/utils/saveCategorySample.js.map +0 -1
- package/lib/module/utils/saveCorrelationSample.js +0 -28
- package/lib/module/utils/saveCorrelationSample.js.map +0 -1
- package/lib/module/utils/saveQuantitySample.js +0 -9
- package/lib/module/utils/saveQuantitySample.js.map +0 -1
- package/lib/module/utils/saveStateOfMindSample.js +0 -10
- package/lib/module/utils/saveStateOfMindSample.js.map +0 -1
- package/lib/module/utils/saveWorkoutRoute.js +0 -19
- package/lib/module/utils/saveWorkoutRoute.js.map +0 -1
- package/lib/module/utils/saveWorkoutSample.js +0 -29
- package/lib/module/utils/saveWorkoutSample.js.map +0 -1
- package/lib/module/utils/serializeDate.js +0 -3
- package/lib/module/utils/serializeDate.js.map +0 -1
- package/lib/module/utils/serializeDate.test.js +0 -14
- package/lib/module/utils/serializeDate.test.js.map +0 -1
- package/lib/module/utils/startWatchApp.js +0 -4
- package/lib/module/utils/startWatchApp.js.map +0 -1
- package/lib/module/utils/subscribeToChanges.js +0 -20
- package/lib/module/utils/subscribeToChanges.js.map +0 -1
- package/lib/typescript/example-expo/App.d.ts +0 -2
- package/lib/typescript/src/hooks/useHealthkitAuthorization.d.ts +0 -8
- package/lib/typescript/src/hooks/useHealthkitAuthorization.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.d.ts +0 -7
- package/lib/typescript/src/hooks/useIsHealthDataAvailable.test.d.ts +0 -1
- package/lib/typescript/src/hooks/useMostRecentCategorySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentQuantitySample.d.ts +0 -7
- package/lib/typescript/src/hooks/useMostRecentWorkout.d.ts +0 -10
- package/lib/typescript/src/hooks/useSources.d.ts +0 -3
- package/lib/typescript/src/hooks/useStatisticsForQuantity.d.ts +0 -4
- package/lib/typescript/src/hooks/useSubscribeToChanges.d.ts +0 -3
- package/lib/typescript/src/index.d.ts +0 -3
- package/lib/typescript/src/index.ios.d.ts +0 -198
- package/lib/typescript/src/index.native.d.ts +0 -41
- package/lib/typescript/src/index.web.d.ts +0 -3
- package/lib/typescript/src/native-types.d.ts +0 -1764
- package/lib/typescript/src/test-setup.d.ts +0 -1
- package/lib/typescript/src/test-utils.d.ts +0 -2
- package/lib/typescript/src/types.d.ts +0 -111
- package/lib/typescript/src/utils/deleteQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/deleteSamples.d.ts +0 -8
- package/lib/typescript/src/utils/deleteWorkoutSample.d.ts +0 -3
- package/lib/typescript/src/utils/deserializeCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeCategorySample.test.d.ts +0 -1
- package/lib/typescript/src/utils/deserializeCorrelation.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeHeartbeatSeriesSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeSample.d.ts +0 -4
- package/lib/typescript/src/utils/deserializeWorkout.d.ts +0 -4
- package/lib/typescript/src/utils/ensureMetadata.d.ts +0 -2
- package/lib/typescript/src/utils/ensureTotals.d.ts +0 -2
- package/lib/typescript/src/utils/ensureUnit.d.ts +0 -3
- package/lib/typescript/src/utils/getDateOfBirth.d.ts +0 -2
- package/lib/typescript/src/utils/getMostRecentCategorySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentQuantitySample.d.ts +0 -4
- package/lib/typescript/src/utils/getMostRecentWorkout.d.ts +0 -5
- package/lib/typescript/src/utils/getPreferredUnit.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnits.d.ts +0 -4
- package/lib/typescript/src/utils/getPreferredUnitsTyped.d.ts +0 -9
- package/lib/typescript/src/utils/getRequestStatusForAuthorization.d.ts +0 -3
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +0 -5
- package/lib/typescript/src/utils/prepareOptions.d.ts +0 -9
- package/lib/typescript/src/utils/queryCategorySamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryCategorySamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryCorrelationSamples.d.ts +0 -5
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamples.d.ts +0 -10
- package/lib/typescript/src/utils/queryHeartbeatSeriesSamplesWithAnchor.d.ts +0 -10
- package/lib/typescript/src/utils/queryQuantitySamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryQuantitySamplesWithAnchor.d.ts +0 -12
- package/lib/typescript/src/utils/querySources.d.ts +0 -4
- package/lib/typescript/src/utils/queryStateOfMindSamples.d.ts +0 -7
- package/lib/typescript/src/utils/queryStatisticsCollectionForQuantity.d.ts +0 -3
- package/lib/typescript/src/utils/queryStatisticsForQuantity.d.ts +0 -14
- package/lib/typescript/src/utils/queryWorkoutSamplesWithAnchor.d.ts +0 -9
- package/lib/typescript/src/utils/queryWorkouts.d.ts +0 -4
- package/lib/typescript/src/utils/requestAuthorization.d.ts +0 -4
- package/lib/typescript/src/utils/saveCategorySample.d.ts +0 -11
- package/lib/typescript/src/utils/saveCorrelationSample.d.ts +0 -8
- package/lib/typescript/src/utils/saveQuantitySample.d.ts +0 -7
- package/lib/typescript/src/utils/saveStateOfMindSample.d.ts +0 -11
- package/lib/typescript/src/utils/saveWorkoutRoute.d.ts +0 -3
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +0 -11
- package/lib/typescript/src/utils/serializeDate.d.ts +0 -2
- package/lib/typescript/src/utils/serializeDate.test.d.ts +0 -1
- package/lib/typescript/src/utils/startWatchApp.d.ts +0 -3
- package/lib/typescript/src/utils/subscribeToChanges.d.ts +0 -3
- package/src/index.ios.tsx +0 -292
- package/src/index.native.tsx +0 -233
- package/src/index.tsx +0 -5
- package/src/index.web.tsx +0 -5
- package/src/native-types.ts +0 -2471
- package/src/types.ts +0 -156
- package/src/utils/deleteQuantitySample.ts +0 -14
- package/src/utils/deleteSamples.ts +0 -23
- package/src/utils/deleteWorkoutSample.ts +0 -7
- package/src/utils/deserializeCategorySample.test.ts +0 -24
- package/src/utils/deserializeCategorySample.ts +0 -12
- package/src/utils/deserializeCorrelation.ts +0 -28
- package/src/utils/deserializeHeartbeatSeriesSample.ts +0 -12
- package/src/utils/deserializeSample.ts +0 -17
- package/src/utils/deserializeWorkout.ts +0 -14
- package/src/utils/ensureMetadata.ts +0 -5
- package/src/utils/ensureTotals.ts +0 -5
- package/src/utils/ensureUnit.ts +0 -19
- package/src/utils/getDateOfBirth.ts +0 -8
- package/src/utils/getPreferredUnits.ts +0 -14
- package/src/utils/getPreferredUnitsTyped.ts +0 -38
- package/src/utils/getRequestStatusForAuthorization.ts +0 -21
- package/src/utils/getWorkoutPlanById.ts +0 -7
- package/src/utils/prepareOptions.ts +0 -19
- package/src/utils/queryCategorySamples.ts +0 -29
- package/src/utils/queryCategorySamplesWithAnchor.ts +0 -39
- package/src/utils/queryCorrelationSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamples.ts +0 -29
- package/src/utils/queryHeartbeatSeriesSamplesWithAnchor.ts +0 -33
- package/src/utils/queryQuantitySamples.ts +0 -38
- package/src/utils/queryQuantitySamplesWithAnchor.ts +0 -46
- package/src/utils/querySources.ts +0 -21
- package/src/utils/queryStateOfMindSamples.ts +0 -14
- package/src/utils/queryStatisticsCollectionForQuantity.ts +0 -38
- package/src/utils/queryStatisticsForQuantity.ts +0 -38
- package/src/utils/queryWorkoutSamplesWithAnchor.ts +0 -46
- package/src/utils/queryWorkouts.ts +0 -28
- package/src/utils/requestAuthorization.ts +0 -19
- package/src/utils/saveCategorySample.ts +0 -31
- package/src/utils/saveCorrelationSample.ts +0 -43
- package/src/utils/saveQuantitySample.ts +0 -29
- package/src/utils/saveStateOfMindSample.ts +0 -38
- package/src/utils/saveWorkoutRoute.ts +0 -21
- package/src/utils/saveWorkoutSample.ts +0 -42
- package/src/utils/serializeDate.test.ts +0 -16
- package/src/utils/serializeDate.ts +0 -5
- package/src/utils/startWatchApp.ts +0 -7
package/ios/Helpers.swift
CHANGED
|
@@ -7,142 +7,392 @@
|
|
|
7
7
|
|
|
8
8
|
import Foundation
|
|
9
9
|
import HealthKit
|
|
10
|
+
import NitroModules
|
|
10
11
|
|
|
11
|
-
func dateOrNilIfZero(
|
|
12
|
-
|
|
12
|
+
func dateOrNilIfZero(_ timestamp: Double?) -> Date? {
|
|
13
|
+
if let timestamp = timestamp {
|
|
14
|
+
if(timestamp == 0){
|
|
15
|
+
return nil
|
|
16
|
+
}
|
|
17
|
+
return Date.init(timeIntervalSince1970: timestamp)
|
|
18
|
+
}
|
|
19
|
+
return nil
|
|
20
|
+
|
|
21
|
+
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
func
|
|
16
|
-
|
|
24
|
+
func getQueryLimit(_ limit: Double?) -> Int {
|
|
25
|
+
if let limit = limit {
|
|
26
|
+
if(limit == .infinity || limit <= 0){
|
|
27
|
+
return HKObjectQueryNoLimit
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return Int(limit)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return DEFAULT_QUERY_LIMIT
|
|
17
34
|
}
|
|
18
35
|
|
|
19
|
-
func
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
func createPredicateForWorkout(filter: PredicateForWorkouts) throws -> NSPredicate {
|
|
37
|
+
switch filter {
|
|
38
|
+
case .first(let uuidWrapper):
|
|
39
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
40
|
+
case .second(let uuidsWrapper):
|
|
41
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
42
|
+
case .third(let metadataKey):
|
|
43
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
44
|
+
case .fourth(let dateFilter):
|
|
45
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
46
|
+
case .fifth(let w):
|
|
47
|
+
if let w = w.workout as? WorkoutProxy {
|
|
48
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
49
|
+
}
|
|
50
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
51
|
+
case .sixth(let activityType):
|
|
52
|
+
if let activityType = HKWorkoutActivityType.init(rawValue: UInt(activityType.workoutActivityType.rawValue)) {
|
|
53
|
+
return HKQuery.predicateForWorkouts(with: activityType)
|
|
54
|
+
} else {
|
|
55
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized workoutActivityType with identifier \(activityType.workoutActivityType.rawValue)")
|
|
56
|
+
}
|
|
57
|
+
case .seventh(let durationPredicate):
|
|
58
|
+
if let op = NSComparisonPredicate.Operator(rawValue: UInt(durationPredicate.predicateOperator.rawValue)){
|
|
59
|
+
return HKQuery.predicateForWorkouts(with: op, duration: durationPredicate.durationInSeconds)
|
|
60
|
+
}
|
|
61
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized workout duration predicate operator \(durationPredicate.predicateOperator.rawValue)")
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func createPredicateForWorkout(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_WorkoutActivityTypePredicate_WorkoutDurationPredicate_PredicateForWorkoutsOr_PredicateForWorkoutsAnd?) throws -> NSPredicate? {
|
|
66
|
+
if let filter = filter {
|
|
67
|
+
switch filter {
|
|
68
|
+
case .first(let uuidWrapper):
|
|
69
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
70
|
+
case .second(let uuidsWrapper):
|
|
71
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
72
|
+
case .third(let metadataKey):
|
|
73
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
74
|
+
case .fourth(let dateFilter):
|
|
75
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
76
|
+
case .fifth(let w):
|
|
77
|
+
if let w = w.workout as? WorkoutProxy {
|
|
78
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
79
|
+
}
|
|
80
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
81
|
+
case .sixth(let activityType):
|
|
82
|
+
if let activityType = HKWorkoutActivityType.init(rawValue: UInt(activityType.workoutActivityType.rawValue)) {
|
|
83
|
+
return HKQuery.predicateForWorkouts(with: activityType)
|
|
84
|
+
} else {
|
|
85
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized workoutActivityType with identifier \(activityType.workoutActivityType.rawValue)")
|
|
86
|
+
}
|
|
87
|
+
case .seventh(let durationPredicate):
|
|
88
|
+
if let op = NSComparisonPredicate.Operator(rawValue: UInt(durationPredicate.predicateOperator.rawValue)){
|
|
89
|
+
return HKQuery.predicateForWorkouts(with: op, duration: durationPredicate.durationInSeconds)
|
|
90
|
+
}
|
|
91
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized workout duration predicate operator \(durationPredicate.predicateOperator.rawValue)")
|
|
92
|
+
|
|
93
|
+
case .eigth(let or):
|
|
94
|
+
return NSCompoundPredicate.init(andPredicateWithSubpredicates: try or.OR.map { predicate in
|
|
95
|
+
return try createPredicateForWorkout(filter: predicate)
|
|
96
|
+
})
|
|
97
|
+
case .ninth(let and):
|
|
98
|
+
return NSCompoundPredicate.init(orPredicateWithSubpredicates: try and.AND
|
|
99
|
+
.map { predicate in
|
|
100
|
+
return try createPredicateForWorkout(filter: predicate)
|
|
101
|
+
})
|
|
102
|
+
}
|
|
25
103
|
}
|
|
104
|
+
|
|
105
|
+
return nil
|
|
26
106
|
}
|
|
27
107
|
|
|
28
|
-
func
|
|
29
|
-
|
|
108
|
+
func createDatePredicate(dateFilter: PredicateWithStartAndEnd) -> NSPredicate {
|
|
109
|
+
let strictStartDate = dateFilter.strictStartDate ?? false
|
|
110
|
+
let strictEndDate = dateFilter.strictEndDate ?? false
|
|
111
|
+
|
|
112
|
+
let options: HKQueryOptions = strictStartDate && strictEndDate
|
|
113
|
+
? [.strictStartDate, .strictEndDate]
|
|
114
|
+
: strictEndDate
|
|
115
|
+
? .strictEndDate
|
|
116
|
+
: strictStartDate
|
|
117
|
+
? .strictStartDate
|
|
118
|
+
: []
|
|
119
|
+
|
|
120
|
+
return HKQuery.predicateForSamples(
|
|
121
|
+
withStart: dateFilter.startDate,
|
|
122
|
+
end: dateFilter.endDate,
|
|
123
|
+
options: options
|
|
124
|
+
)
|
|
30
125
|
}
|
|
31
126
|
|
|
32
|
-
func
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
127
|
+
func createUUIDsPredicate(uuidsWrapper: PredicateWithUUIDs) -> NSPredicate {
|
|
128
|
+
let uuids = uuidsWrapper.uuids.compactMap { uuidStr -> UUID? in
|
|
129
|
+
do {
|
|
130
|
+
let uuid = try initializeUUID(uuidStr)
|
|
131
|
+
return uuid
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
print(error.localizedDescription)
|
|
135
|
+
return nil
|
|
136
|
+
}
|
|
37
137
|
}
|
|
138
|
+
return HKQuery.predicateForObjects(with: Set(uuids))
|
|
139
|
+
}
|
|
38
140
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
141
|
+
func createPredicate(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout?) throws -> NSPredicate? {
|
|
142
|
+
if let filter = filter {
|
|
143
|
+
switch filter {
|
|
144
|
+
case .first(let uuidWrapper):
|
|
145
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
146
|
+
case .second(let uuidsWrapper):
|
|
147
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
148
|
+
case .third(let metadataKey):
|
|
149
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
150
|
+
case .fourth(let dateFilter):
|
|
151
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
152
|
+
case .fifth(let w):
|
|
153
|
+
if let w = w.workout as? WorkoutProxy {
|
|
154
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
155
|
+
}
|
|
156
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return nil
|
|
160
|
+
}
|
|
44
161
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
162
|
+
func createPredicate(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_FilterForSamplesAnd_FilterForSamplesOr?) throws -> NSPredicate? {
|
|
163
|
+
if let filter = filter {
|
|
164
|
+
switch filter {
|
|
165
|
+
case .first(let uuidWrapper):
|
|
166
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
167
|
+
case .second(let uuidsWrapper):
|
|
168
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
169
|
+
case .third(let metadataKey):
|
|
170
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
171
|
+
case .fourth(let dateFilter):
|
|
172
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
173
|
+
case .fifth(let w):
|
|
174
|
+
if let w = w.workout as? WorkoutProxy {
|
|
175
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
176
|
+
}
|
|
177
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
178
|
+
case .sixth(let and):
|
|
179
|
+
return NSCompoundPredicate.init(andPredicateWithSubpredicates: try and.AND.map { predicate in
|
|
180
|
+
return try createPredicateForSamples(filter: predicate)
|
|
181
|
+
})
|
|
182
|
+
case .seventh(let or):
|
|
183
|
+
return NSCompoundPredicate.init(orPredicateWithSubpredicates: try or.OR
|
|
184
|
+
.map { predicate in
|
|
185
|
+
return try createPredicateForSamples(filter: predicate)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
49
188
|
}
|
|
189
|
+
return nil
|
|
50
190
|
}
|
|
51
191
|
|
|
52
|
-
func
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
192
|
+
func createPredicateForSamples(filter: PredicateForSamples) throws -> NSPredicate {
|
|
193
|
+
switch filter {
|
|
194
|
+
case .first(let uuidWrapper):
|
|
195
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
196
|
+
case .second(let uuidsWrapper):
|
|
197
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
198
|
+
case .third(let metadataKey):
|
|
199
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
200
|
+
case .fourth(let dateFilter):
|
|
201
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
202
|
+
case .fifth(let w):
|
|
203
|
+
if let w = w.workout as? WorkoutProxy {
|
|
204
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
205
|
+
}
|
|
206
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
56
207
|
}
|
|
208
|
+
}
|
|
57
209
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
210
|
+
func createPredicateForSamples(filter: FilterForSamples) throws -> NSPredicate {
|
|
211
|
+
switch filter {
|
|
212
|
+
case .first(let uuidWrapper):
|
|
213
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
214
|
+
case .second(let uuidsWrapper):
|
|
215
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
216
|
+
case .third(let metadataKey):
|
|
217
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
218
|
+
case .fourth(let dateFilter):
|
|
219
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
220
|
+
case .fifth(let w):
|
|
221
|
+
if let w = w.workout as? WorkoutProxy {
|
|
222
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
223
|
+
}
|
|
224
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
225
|
+
case .sixth(let and):
|
|
226
|
+
return NSCompoundPredicate.init(andPredicateWithSubpredicates: try and.AND.map { predicate in
|
|
227
|
+
return try createPredicateForSamples(filter: predicate)
|
|
228
|
+
})
|
|
229
|
+
case .seventh(let or):
|
|
230
|
+
return NSCompoundPredicate.init(orPredicateWithSubpredicates: try or.OR
|
|
231
|
+
.map { predicate in
|
|
232
|
+
return try createPredicateForSamples(filter: predicate)
|
|
233
|
+
})
|
|
61
234
|
}
|
|
235
|
+
}
|
|
62
236
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
237
|
+
func createPredicateForSamples(filter: Variant_PredicateWithUUID_PredicateWithUUIDs_PredicateWithMetadataKey_PredicateWithStartAndEnd_PredicateFromWorkout_FilterForSamplesAnd_FilterForSamplesOr) throws -> NSPredicate {
|
|
238
|
+
switch filter {
|
|
239
|
+
case .first(let uuidWrapper):
|
|
240
|
+
return HKQuery.predicateForObject(with: try initializeUUID(uuidWrapper.uuid))
|
|
241
|
+
case .second(let uuidsWrapper):
|
|
242
|
+
return createUUIDsPredicate(uuidsWrapper: uuidsWrapper)
|
|
243
|
+
case .third(let metadataKey):
|
|
244
|
+
return HKQuery.predicateForObjects(withMetadataKey: metadataKey.withMetadataKey)
|
|
245
|
+
case .fourth(let dateFilter):
|
|
246
|
+
return createDatePredicate(dateFilter: dateFilter)
|
|
247
|
+
case .fifth(let w):
|
|
248
|
+
if let w = w.workout as? WorkoutProxy {
|
|
249
|
+
return HKQuery.predicateForObjects(from: w.workout)
|
|
250
|
+
}
|
|
251
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize workout for filter")
|
|
252
|
+
case .sixth(let and):
|
|
253
|
+
return NSCompoundPredicate.init(andPredicateWithSubpredicates: try and.AND.map { predicate in
|
|
254
|
+
return try createPredicateForSamples(filter: predicate)
|
|
255
|
+
})
|
|
256
|
+
case .seventh(let or):
|
|
257
|
+
return NSCompoundPredicate.init(orPredicateWithSubpredicates: try or.OR
|
|
258
|
+
.map { predicate in
|
|
259
|
+
return try createPredicateForSamples(filter: predicate)
|
|
260
|
+
})
|
|
66
261
|
}
|
|
262
|
+
}
|
|
67
263
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
264
|
+
func getSortDescriptors(ascending: Bool?) -> [NSSortDescriptor] {
|
|
265
|
+
return [NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: ascending ?? false)]
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
func getSortDescsdsdriptors(ascending: Bool?) -> [NSSortDescriptor] {
|
|
269
|
+
return [NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: ascending ?? false)]
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
func deserializeHKQueryAnchor(base64String: String?) throws -> HKQueryAnchor? {
|
|
273
|
+
if let base64String = base64String {
|
|
274
|
+
if base64String.isEmpty {
|
|
275
|
+
return nil
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Step 1: Decode the base64 string to a Data object
|
|
279
|
+
guard let data = Data(base64Encoded: base64String) else {
|
|
280
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Invalid base64 string: \(base64String)")
|
|
71
281
|
}
|
|
72
|
-
}
|
|
73
282
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
283
|
+
// Step 2: Use NSKeyedUnarchiver to unarchive the data and create an HKQueryAnchor object
|
|
284
|
+
do {
|
|
285
|
+
let unarchiver = try NSKeyedUnarchiver(forReadingFrom: data)
|
|
286
|
+
unarchiver.requiresSecureCoding = true
|
|
287
|
+
let anchor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data)
|
|
288
|
+
|
|
289
|
+
return anchor as? HKQueryAnchor
|
|
290
|
+
} catch {
|
|
291
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Error recreating HKQueryAnchor object: \(error.localizedDescription)")
|
|
79
292
|
}
|
|
80
|
-
|
|
293
|
+
}
|
|
294
|
+
return nil
|
|
295
|
+
}
|
|
81
296
|
|
|
82
|
-
|
|
83
|
-
|
|
297
|
+
|
|
298
|
+
func initializeCategoryType(_ identifier: String) throws -> HKCategoryType {
|
|
299
|
+
let identifier = HKCategoryTypeIdentifier(rawValue: identifier)
|
|
300
|
+
if let sampleType = HKSampleType.categoryType(forIdentifier: identifier) {
|
|
301
|
+
return sampleType
|
|
84
302
|
}
|
|
303
|
+
|
|
304
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized categoryType with identifier \(identifier)")
|
|
305
|
+
}
|
|
85
306
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
307
|
+
func initializeWorkoutActivityType(_ typeIdentifier: UInt) throws -> HKWorkoutActivityType {
|
|
308
|
+
if let type = HKWorkoutActivityType.init(rawValue: typeIdentifier) {
|
|
309
|
+
return type
|
|
90
310
|
}
|
|
311
|
+
|
|
312
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized quantityType with identifier \(typeIdentifier)")
|
|
313
|
+
}
|
|
91
314
|
|
|
92
|
-
|
|
315
|
+
func initializeQuantityType(_ identifier: String) throws -> HKQuantityType {
|
|
316
|
+
let identifier = HKQuantityTypeIdentifier(rawValue: identifier)
|
|
317
|
+
|
|
318
|
+
if let sampleType = HKSampleType.quantityType(forIdentifier: identifier) {
|
|
319
|
+
return sampleType
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized quantityType with identifier \(identifier)")
|
|
93
323
|
}
|
|
94
324
|
|
|
95
|
-
func
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
if objectType != nil {
|
|
101
|
-
share.insert(objectType!)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
325
|
+
func initializeCorrelationType(_ identifier: String) throws -> HKCorrelationType {
|
|
326
|
+
let identifier = HKCorrelationTypeIdentifier(rawValue: identifier)
|
|
327
|
+
|
|
328
|
+
if let sampleType = HKSampleType.correlationType(forIdentifier: identifier) {
|
|
329
|
+
return sampleType
|
|
104
330
|
}
|
|
105
|
-
|
|
331
|
+
|
|
332
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized correlationType with identifier \(identifier)")
|
|
106
333
|
}
|
|
107
334
|
|
|
108
|
-
func
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if item.value as! Bool {
|
|
112
|
-
let sampleType = sampleTypeFromString(typeIdentifier: item.key as! String)
|
|
113
|
-
if sampleType != nil {
|
|
114
|
-
share.insert(sampleType!)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
335
|
+
func initializeSeriesType(_ identifier: String) throws -> HKSeriesType {
|
|
336
|
+
if let seriesType = HKObjectType.seriesType(forIdentifier: identifier) {
|
|
337
|
+
return seriesType
|
|
117
338
|
}
|
|
118
|
-
|
|
339
|
+
|
|
340
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized seriesType with identifier \(identifier)")
|
|
119
341
|
}
|
|
120
342
|
|
|
121
|
-
func
|
|
122
|
-
if typeIdentifier
|
|
123
|
-
|
|
124
|
-
return HKObjectType.characteristicType(forIdentifier: identifier) as HKObjectType?
|
|
343
|
+
func sampleTypeFrom(sampleTypeIdentifier: SampleTypeIdentifier) throws -> HKSampleType {
|
|
344
|
+
if let sampleType = try sampleTypeFromStringNullable(typeIdentifier: sampleTypeIdentifier.stringValue) {
|
|
345
|
+
return sampleType
|
|
125
346
|
}
|
|
347
|
+
|
|
348
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized sampleType with identifier \(sampleTypeIdentifier.stringValue)")
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
func sampleTypeFrom(sampleTypeIdentifierWriteable: SampleTypeIdentifierWriteable) throws -> HKSampleType {
|
|
352
|
+
if let sampleType = try sampleTypeFromStringNullable(typeIdentifier: sampleTypeIdentifierWriteable.stringValue) {
|
|
353
|
+
return sampleType
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed to initialize unrecognized sampleType with identifier \(sampleTypeIdentifierWriteable.stringValue)")
|
|
357
|
+
}
|
|
126
358
|
|
|
359
|
+
private func sampleTypeFromStringNullable(typeIdentifier: String) throws -> HKSampleType? {
|
|
127
360
|
if typeIdentifier.starts(with: HKQuantityTypeIdentifier_PREFIX) {
|
|
128
|
-
|
|
129
|
-
return HKObjectType.quantityType(forIdentifier: identifier) as HKObjectType?
|
|
361
|
+
return try initializeQuantityType(typeIdentifier)
|
|
130
362
|
}
|
|
131
363
|
|
|
132
364
|
if typeIdentifier.starts(with: HKCategoryTypeIdentifier_PREFIX) {
|
|
133
|
-
|
|
134
|
-
return HKObjectType.categoryType(forIdentifier: identifier) as HKObjectType?
|
|
365
|
+
return try initializeCategoryType(typeIdentifier)
|
|
135
366
|
}
|
|
136
367
|
|
|
137
368
|
if typeIdentifier.starts(with: HKCorrelationTypeIdentifier_PREFIX) {
|
|
138
|
-
|
|
139
|
-
|
|
369
|
+
return try initializeCorrelationType(typeIdentifier)
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
if typeIdentifier == HKWorkoutTypeIdentifier {
|
|
373
|
+
return HKSampleType.workoutType()
|
|
140
374
|
}
|
|
141
375
|
|
|
142
|
-
if
|
|
143
|
-
|
|
376
|
+
if #available(iOS 11.0, *) {
|
|
377
|
+
if typeIdentifier == HKWorkoutRouteTypeIdentifier {
|
|
378
|
+
return try initializeSeriesType(typeIdentifier)
|
|
379
|
+
}
|
|
144
380
|
}
|
|
145
381
|
|
|
382
|
+
if #available(iOS 13, *) {
|
|
383
|
+
if typeIdentifier == HKAudiogramTypeIdentifier {
|
|
384
|
+
return HKObjectType.audiogramSampleType()
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if typeIdentifier == HKDataTypeIdentifierHeartbeatSeries {
|
|
388
|
+
return try initializeSeriesType(typeIdentifier)
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if typeIdentifier == HKAudiogramTypeIdentifier {
|
|
392
|
+
return HKSampleType.audiogramSampleType()
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
146
396
|
#if compiler(>=6)
|
|
147
397
|
if #available(iOS 18, *) {
|
|
148
398
|
if typeIdentifier == HKStateOfMindTypeIdentifier {
|
|
@@ -151,27 +401,74 @@ func objectTypeFromString(typeIdentifier: String) -> HKObjectType? {
|
|
|
151
401
|
}
|
|
152
402
|
#endif
|
|
153
403
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return HKObjectType.audiogramSampleType()
|
|
157
|
-
}
|
|
404
|
+
return nil
|
|
405
|
+
}
|
|
158
406
|
|
|
159
|
-
|
|
160
|
-
|
|
407
|
+
func objectTypesFromArray(typeIdentifiers: [ObjectTypeIdentifier]) -> Set<HKObjectType> {
|
|
408
|
+
var share = Set<HKObjectType>()
|
|
409
|
+
for typeIdentifier in typeIdentifiers {
|
|
410
|
+
do {
|
|
411
|
+
let objectType = try objectTypeFrom(objectTypeIdentifier: typeIdentifier)
|
|
412
|
+
share.insert(objectType)
|
|
413
|
+
} catch {
|
|
414
|
+
print(error.localizedDescription)
|
|
161
415
|
}
|
|
162
416
|
}
|
|
417
|
+
return share
|
|
418
|
+
}
|
|
163
419
|
|
|
164
|
-
|
|
165
|
-
|
|
420
|
+
func initializeUUID(_ uuidString: String) throws -> UUID {
|
|
421
|
+
if let uuid = UUID(uuidString: uuidString) {
|
|
422
|
+
return uuid
|
|
166
423
|
}
|
|
424
|
+
|
|
425
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Got invalid UUID: \(uuidString)")
|
|
426
|
+
}
|
|
167
427
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
428
|
+
func sampleTypesFromArray(typeIdentifiers: [SampleTypeIdentifier]) -> Set<HKSampleType> {
|
|
429
|
+
return Set(typeIdentifiers.compactMap { typeIdentifier in
|
|
430
|
+
do {
|
|
431
|
+
let sampleType = try sampleTypeFrom(sampleTypeIdentifier: typeIdentifier)
|
|
432
|
+
return sampleType
|
|
433
|
+
} catch {
|
|
434
|
+
print(error.localizedDescription)
|
|
435
|
+
}
|
|
436
|
+
return nil
|
|
437
|
+
})
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
func sampleTypesFromArray(typeIdentifiersWriteable: [SampleTypeIdentifierWriteable]) -> Set<HKSampleType> {
|
|
441
|
+
return Set(typeIdentifiersWriteable.compactMap { typeIdentifier in
|
|
442
|
+
do {
|
|
443
|
+
let sampleType = try sampleTypeFrom(sampleTypeIdentifierWriteable: typeIdentifier)
|
|
444
|
+
return sampleType
|
|
445
|
+
} catch {
|
|
446
|
+
print(error.localizedDescription)
|
|
447
|
+
}
|
|
448
|
+
return nil
|
|
449
|
+
})
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
// objectType is wider than sampleType, so it uses it under the hood
|
|
454
|
+
func objectTypeFrom(objectTypeIdentifier: ObjectTypeIdentifier) throws -> HKObjectType {
|
|
455
|
+
let typeIdentifier = objectTypeIdentifier.stringValue
|
|
456
|
+
if let sampleType = try sampleTypeFromStringNullable(typeIdentifier: typeIdentifier) {
|
|
457
|
+
return sampleType
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
if typeIdentifier.starts(with: HKCharacteristicTypeIdentifier_PREFIX) {
|
|
461
|
+
let identifier = HKCharacteristicTypeIdentifier.init(rawValue: typeIdentifier)
|
|
462
|
+
if let type = HKObjectType.characteristicType(forIdentifier: identifier) as HKObjectType? {
|
|
463
|
+
return type
|
|
171
464
|
}
|
|
172
465
|
}
|
|
173
466
|
|
|
174
|
-
|
|
467
|
+
if typeIdentifier == HKActivitySummaryTypeIdentifier {
|
|
468
|
+
return HKObjectType.activitySummaryType()
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
throw RuntimeError.error(withMessage: "[react-native-healthkit] Failed initializing unrecognized objectType identifier " + typeIdentifier)
|
|
175
472
|
}
|
|
176
473
|
|
|
177
474
|
func hkStatisticsOptionsFromOptions(_ options: NSArray) -> HKStatisticsOptions {
|
|
@@ -189,10 +486,6 @@ func hkStatisticsOptionsFromOptions(_ options: NSArray) -> HKStatisticsOptions {
|
|
|
189
486
|
opts.insert(.discreteMax)
|
|
190
487
|
case "discreteMin":
|
|
191
488
|
opts.insert(.discreteMin)
|
|
192
|
-
case "discreteMostRecent":
|
|
193
|
-
if #available(iOS 12, *) {
|
|
194
|
-
opts.insert(.discreteMostRecent)
|
|
195
|
-
}
|
|
196
489
|
case "duration":
|
|
197
490
|
if #available(iOS 13, *) {
|
|
198
491
|
opts.insert(.duration)
|
|
@@ -229,166 +522,151 @@ func componentsFromInterval(_ interval: NSDictionary) -> DateComponents {
|
|
|
229
522
|
return intervalComponents
|
|
230
523
|
}
|
|
231
524
|
|
|
232
|
-
func
|
|
233
|
-
guard let quantity = quantity else { return nil }
|
|
234
|
-
return serializeQuantity(unit: unit, quantity: quantity)
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
func serializeStatisticIfExists(unit: HKUnit, quantity: HKQuantity?, stats: HKStatistics)
|
|
238
|
-
-> [String: Any]? {
|
|
239
|
-
guard let quantity = quantity else { return nil }
|
|
240
|
-
return serializeStatistic(unit: unit, quantity: quantity, stats: stats)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
func parseWorkoutConfiguration(_ dict: NSDictionary) -> HKWorkoutConfiguration {
|
|
525
|
+
func parseWorkoutConfiguration(_ config: WorkoutConfiguration) -> HKWorkoutConfiguration {
|
|
244
526
|
let configuration = HKWorkoutConfiguration()
|
|
245
527
|
|
|
246
|
-
if let
|
|
247
|
-
|
|
248
|
-
configuration.activityType = activityType
|
|
528
|
+
if let activityType = HKWorkoutActivityType(rawValue: UInt(config.activityType.rawValue)) {
|
|
529
|
+
configuration.activityType = activityType
|
|
249
530
|
}
|
|
250
531
|
|
|
251
|
-
if let locationTypeRaw =
|
|
252
|
-
|
|
532
|
+
if let locationTypeRaw = config.locationType,
|
|
533
|
+
let locationType = HKWorkoutSessionLocationType(rawValue: Int(locationTypeRaw.rawValue)) {
|
|
253
534
|
configuration.locationType = locationType
|
|
254
535
|
}
|
|
255
536
|
|
|
256
537
|
return configuration
|
|
257
538
|
}
|
|
258
539
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
540
|
+
// Returns all available HKQuantityTypeIdentifier raw values as an array of String
|
|
541
|
+
func allQuantityTypeIdentifiers() -> [String] {
|
|
542
|
+
let allIdentifiers: [HKQuantityTypeIdentifier] = [
|
|
543
|
+
.bodyMassIndex,
|
|
544
|
+
.bodyFatPercentage,
|
|
545
|
+
.height,
|
|
546
|
+
.bodyMass,
|
|
547
|
+
.leanBodyMass,
|
|
548
|
+
.waistCircumference,
|
|
549
|
+
.stepCount,
|
|
550
|
+
.distanceWalkingRunning,
|
|
551
|
+
.distanceCycling,
|
|
552
|
+
.distanceWheelchair,
|
|
553
|
+
.basalEnergyBurned,
|
|
554
|
+
.activeEnergyBurned,
|
|
555
|
+
.flightsClimbed,
|
|
556
|
+
.nikeFuel,
|
|
557
|
+
.appleExerciseTime,
|
|
558
|
+
.pushCount,
|
|
559
|
+
.distanceSwimming,
|
|
560
|
+
.swimmingStrokeCount,
|
|
561
|
+
.vo2Max,
|
|
562
|
+
.distanceDownhillSnowSports,
|
|
563
|
+
.appleStandTime,
|
|
564
|
+
.walkingSpeed,
|
|
565
|
+
.walkingDoubleSupportPercentage,
|
|
566
|
+
.walkingAsymmetryPercentage,
|
|
567
|
+
.walkingStepLength,
|
|
568
|
+
.sixMinuteWalkTestDistance,
|
|
569
|
+
.stairAscentSpeed,
|
|
570
|
+
.stairDescentSpeed,
|
|
571
|
+
.heartRate,
|
|
572
|
+
.bodyTemperature,
|
|
573
|
+
.basalBodyTemperature,
|
|
574
|
+
.bloodPressureSystolic,
|
|
575
|
+
.bloodPressureDiastolic,
|
|
576
|
+
.respiratoryRate,
|
|
577
|
+
.restingHeartRate,
|
|
578
|
+
.walkingHeartRateAverage,
|
|
579
|
+
.heartRateVariabilitySDNN,
|
|
580
|
+
.oxygenSaturation,
|
|
581
|
+
.peripheralPerfusionIndex,
|
|
582
|
+
.bloodGlucose,
|
|
583
|
+
.numberOfTimesFallen,
|
|
584
|
+
.electrodermalActivity,
|
|
585
|
+
.inhalerUsage,
|
|
586
|
+
.insulinDelivery,
|
|
587
|
+
.bloodAlcoholContent,
|
|
588
|
+
.forcedVitalCapacity,
|
|
589
|
+
.forcedExpiratoryVolume1,
|
|
590
|
+
.peakExpiratoryFlowRate,
|
|
591
|
+
.environmentalAudioExposure,
|
|
592
|
+
.headphoneAudioExposure,
|
|
593
|
+
.dietaryFatTotal,
|
|
594
|
+
.dietaryFatPolyunsaturated,
|
|
595
|
+
.dietaryFatMonounsaturated,
|
|
596
|
+
.dietaryFatSaturated,
|
|
597
|
+
.dietaryCholesterol,
|
|
598
|
+
.dietarySodium,
|
|
599
|
+
.dietaryCarbohydrates,
|
|
600
|
+
.dietaryFiber,
|
|
601
|
+
.dietarySugar,
|
|
602
|
+
.dietaryEnergyConsumed,
|
|
603
|
+
.dietaryProtein,
|
|
604
|
+
.dietaryVitaminA,
|
|
605
|
+
.dietaryVitaminB6,
|
|
606
|
+
.dietaryVitaminB12,
|
|
607
|
+
.dietaryVitaminC,
|
|
608
|
+
.dietaryVitaminD,
|
|
609
|
+
.dietaryVitaminE,
|
|
610
|
+
.dietaryVitaminK,
|
|
611
|
+
.dietaryCalcium,
|
|
612
|
+
.dietaryIron,
|
|
613
|
+
.dietaryThiamin,
|
|
614
|
+
.dietaryRiboflavin,
|
|
615
|
+
.dietaryNiacin,
|
|
616
|
+
.dietaryFolate,
|
|
617
|
+
.dietaryBiotin,
|
|
618
|
+
.dietaryPantothenicAcid,
|
|
619
|
+
.dietaryPhosphorus,
|
|
620
|
+
.dietaryIodine,
|
|
621
|
+
.dietaryMagnesium,
|
|
622
|
+
.dietaryZinc,
|
|
623
|
+
.dietarySelenium,
|
|
624
|
+
.dietaryCopper,
|
|
625
|
+
.dietaryManganese,
|
|
626
|
+
.dietaryChromium,
|
|
627
|
+
.dietaryMolybdenum,
|
|
628
|
+
.dietaryChloride,
|
|
629
|
+
.dietaryPotassium,
|
|
630
|
+
.dietaryCaffeine,
|
|
631
|
+
.dietaryWater,
|
|
632
|
+
.uvExposure
|
|
633
|
+
// Add more identifiers as needed for your iOS version
|
|
338
634
|
]
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
case .family: "Family"
|
|
361
|
-
case .fitness: "Fitness"
|
|
362
|
-
case .friends: "Friends"
|
|
363
|
-
case .health: "Health"
|
|
364
|
-
case .hobbies: "Hobbies"
|
|
365
|
-
case .identity: "Identity"
|
|
366
|
-
case .money: "Money"
|
|
367
|
-
case .partner: "Partner"
|
|
368
|
-
case .selfCare: "Self Care"
|
|
369
|
-
case .spirituality: "Spirituality"
|
|
370
|
-
case .tasks: "Tasks"
|
|
371
|
-
case .travel: "Travel"
|
|
372
|
-
case .work: "Work"
|
|
373
|
-
case .weather: "Weather"
|
|
374
|
-
@unknown default: "Unknown"
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
public static var allCases: [HKStateOfMind.Association] {
|
|
379
|
-
[
|
|
380
|
-
.community, .currentEvents, .dating, .education, .family,
|
|
381
|
-
.fitness, .friends, .health, .hobbies, .identity,
|
|
382
|
-
.money, .partner, .selfCare, .spirituality, .tasks,
|
|
383
|
-
.travel, .work, .weather
|
|
635
|
+
let supported = allIdentifiers.compactMap { identifier in
|
|
636
|
+
HKObjectType.quantityType(forIdentifier: identifier) != nil ? identifier.rawValue : nil
|
|
637
|
+
}
|
|
638
|
+
let missing = allIdentifiers.filter { HKObjectType.quantityType(forIdentifier: $0) == nil }
|
|
639
|
+
if !missing.isEmpty {
|
|
640
|
+
print("[react-native-healthkit] Warning: The following HKQuantityTypeIdentifiers are not available on this iOS version: \(missing.map { $0.rawValue })")
|
|
641
|
+
}
|
|
642
|
+
// --- New logic: Warn if any available identifier is not in the hardcoded list ---
|
|
643
|
+
// Try common HealthKit identifier strings (brute-force, as Apple does not provide a list)
|
|
644
|
+
let knownPrefixes = [
|
|
645
|
+
"HKQuantityTypeIdentifier",
|
|
646
|
+
"HKQuantityTypeIdentifierDietary",
|
|
647
|
+
"HKQuantityTypeIdentifierEnvironmental",
|
|
648
|
+
"HKQuantityTypeIdentifierBlood",
|
|
649
|
+
"HKQuantityTypeIdentifierBody",
|
|
650
|
+
"HKQuantityTypeIdentifierDistance",
|
|
651
|
+
"HKQuantityTypeIdentifierHeart",
|
|
652
|
+
"HKQuantityTypeIdentifierRespiratory",
|
|
653
|
+
"HKQuantityTypeIdentifierWalking",
|
|
654
|
+
"HKQuantityTypeIdentifierSwimming",
|
|
655
|
+
"HKQuantityTypeIdentifierApple"
|
|
384
656
|
]
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
657
|
+
var foundButNotListed: [String] = []
|
|
658
|
+
// Try all possible identifier strings (brute-force for demonstration, not exhaustive)
|
|
659
|
+
for codePoint in 0..<300 {
|
|
660
|
+
for prefix in knownPrefixes {
|
|
661
|
+
let candidate = prefix + String(codePoint)
|
|
662
|
+
if let type = HKObjectType.quantityType(forIdentifier: HKQuantityTypeIdentifier(rawValue: candidate)),
|
|
663
|
+
!allIdentifiers.contains(where: { $0.rawValue == candidate }) {
|
|
664
|
+
foundButNotListed.append(candidate)
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
if !foundButNotListed.isEmpty {
|
|
669
|
+
print("[react-native-healthkit] Warning: The following HKQuantityTypeIdentifiers are available on this iOS version but NOT included in the hardcoded list: \(foundButNotListed)")
|
|
670
|
+
}
|
|
671
|
+
return supported
|
|
393
672
|
}
|
|
394
|
-
#endif
|