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