@kingstinct/react-native-healthkit 11.1.2 → 12.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/ios/CoreModule.swift +6 -6
- package/ios/Helpers.swift +5 -5
- package/ios/QuantityTypeModule.swift +5 -19
- package/ios/WorkoutsModule.swift +14 -14
- package/lib/commonjs/healthkit.ios.js +11 -6
- package/lib/commonjs/healthkit.js +12 -4
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +14 -8
- package/lib/commonjs/hooks/useSubscribeToQuantitySamples.js +20 -0
- package/lib/commonjs/utils/subscribeToQuantitySamples.js +47 -0
- package/lib/module/healthkit.ios.js +6 -4
- package/lib/module/healthkit.js +11 -3
- package/lib/module/hooks/useHealthkitAuthorization.js +14 -8
- package/lib/module/hooks/useSubscribeToQuantitySamples.js +17 -0
- package/lib/module/utils/subscribeToQuantitySamples.js +43 -0
- package/lib/typescript/healthkit.d.ts +19 -9
- package/lib/typescript/healthkit.ios.d.ts +27 -18
- package/lib/typescript/hooks/useHealthkitAuthorization.d.ts +4 -1
- package/lib/typescript/hooks/useSubscribeToQuantitySamples.d.ts +3 -0
- package/lib/typescript/specs/CharacteristicTypeModule.nitro.d.ts +2 -2
- package/lib/typescript/specs/CoreModule.nitro.d.ts +7 -2
- package/lib/typescript/specs/QuantityTypeModule.nitro.d.ts +1 -1
- package/lib/typescript/specs/WorkoutProxy.nitro.d.ts +3 -11
- package/lib/typescript/specs/WorkoutsModule.nitro.d.ts +1 -1
- package/lib/typescript/types/Device.d.ts +8 -8
- package/lib/typescript/types/Source.d.ts +2 -2
- package/lib/typescript/types/Subscriptions.d.ts +14 -1
- package/lib/typescript/types/Workouts.d.ts +1 -1
- package/lib/typescript/utils/subscribeToQuantitySamples.d.ts +5 -0
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Bridge.hpp +94 -55
- package/nitrogen/generated/ios/ReactNativeHealthkit-Swift-Cxx-Umbrella.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridCategoryTypeModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridCharacteristicTypeModuleSpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridCoreModuleSpecSwift.hpp +10 -4
- package/nitrogen/generated/ios/c++/HybridCorrelationTypeModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridElectrocardiogramModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridHeartbeatSeriesModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridQuantityTypeModuleSpecSwift.hpp +4 -3
- package/nitrogen/generated/ios/c++/HybridSourceProxySpecSwift.hpp +3 -0
- package/nitrogen/generated/ios/c++/HybridStateOfMindModuleSpecSwift.hpp +3 -2
- package/nitrogen/generated/ios/c++/HybridWorkoutProxySpecSwift.hpp +7 -22
- package/nitrogen/generated/ios/c++/HybridWorkoutsModuleSpecSwift.hpp +5 -4
- package/nitrogen/generated/ios/swift/AuthDataTypes.swift +108 -0
- package/nitrogen/generated/ios/swift/ECGQueryOptionsWithSortOrder.swift +16 -2
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridCategoryTypeModuleSpec_cxx.swift +10 -1
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridCharacteristicTypeModuleSpec_cxx.swift +10 -1
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec.swift +10 -2
- package/nitrogen/generated/ios/swift/HybridCoreModuleSpec_cxx.swift +24 -36
- package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridCorrelationTypeModuleSpec_cxx.swift +10 -1
- package/nitrogen/generated/ios/swift/HybridElectrocardiogramModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridElectrocardiogramModuleSpec_cxx.swift +10 -1
- package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridHeartbeatSeriesModuleSpec_cxx.swift +10 -1
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec.swift +9 -1
- package/nitrogen/generated/ios/swift/HybridQuantityTypeModuleSpec_cxx.swift +13 -12
- package/nitrogen/generated/ios/swift/HybridSourceProxySpec.swift +7 -0
- package/nitrogen/generated/ios/swift/HybridSourceProxySpec_cxx.swift +9 -1
- package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec.swift +8 -0
- package/nitrogen/generated/ios/swift/HybridStateOfMindModuleSpec_cxx.swift +11 -10
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec.swift +8 -4
- package/nitrogen/generated/ios/swift/HybridWorkoutProxySpec_cxx.swift +10 -53
- package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec.swift +9 -1
- package/nitrogen/generated/ios/swift/HybridWorkoutsModuleSpec_cxx.swift +19 -3
- package/nitrogen/generated/ios/swift/PredicateWithMetadataKey.swift +21 -21
- package/nitrogen/generated/ios/swift/PredicateWithStartAndEnd.swift +16 -2
- package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrder.swift +8 -1
- package/nitrogen/generated/ios/swift/QueryOptionsWithSortOrderAndUnit.swift +8 -1
- package/nitrogen/generated/ios/swift/StateOfMindSample.swift +29 -21
- package/nitrogen/generated/ios/swift/{Variant_String_Double_Bool_Date.swift → Variant_Bool_String_Double_Date.swift} +6 -6
- package/nitrogen/generated/ios/swift/WorkoutQueryOptions.swift +8 -1
- package/nitrogen/generated/shared/c++/AuthDataTypes.hpp +85 -0
- package/nitrogen/generated/shared/c++/CategorySample.hpp +0 -2
- package/nitrogen/generated/shared/c++/CategorySampleForSaving.hpp +0 -2
- package/nitrogen/generated/shared/c++/CorrelationSample.hpp +0 -2
- package/nitrogen/generated/shared/c++/DeletedSample.hpp +1 -2
- package/nitrogen/generated/shared/c++/ElectrocardiogramSample.hpp +0 -2
- package/nitrogen/generated/shared/c++/HeartbeatSeriesSample.hpp +0 -2
- package/nitrogen/generated/shared/c++/HybridCategoryTypeModuleSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/HybridCoreModuleSpec.hpp +5 -5
- package/nitrogen/generated/shared/c++/HybridCorrelationTypeModuleSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/HybridQuantityTypeModuleSpec.hpp +1 -3
- package/nitrogen/generated/shared/c++/HybridStateOfMindModuleSpec.hpp +0 -2
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.cpp +0 -4
- package/nitrogen/generated/shared/c++/HybridWorkoutProxySpec.hpp +4 -10
- package/nitrogen/generated/shared/c++/HybridWorkoutsModuleSpec.hpp +2 -3
- package/nitrogen/generated/shared/c++/PredicateWithMetadataKey.hpp +5 -5
- package/nitrogen/generated/shared/c++/QuantitySample.hpp +0 -2
- package/nitrogen/generated/shared/c++/QuantitySampleForSaving.hpp +0 -2
- package/nitrogen/generated/shared/c++/StateOfMindSample.hpp +0 -2
- package/nitrogen/generated/shared/c++/WorkoutSample.hpp +0 -2
- package/package.json +7 -7
- package/src/healthkit.ios.ts +11 -6
- package/src/healthkit.ts +19 -6
- package/src/hooks/useHealthkitAuthorization.test.ts +12 -4
- package/src/hooks/useHealthkitAuthorization.ts +20 -14
- package/src/hooks/useSubscribeToQuantitySamples.ts +31 -0
- package/src/specs/CategoryTypeModule.nitro.ts +1 -1
- package/src/specs/CharacteristicTypeModule.nitro.ts +2 -2
- package/src/specs/CoreModule.nitro.ts +8 -6
- package/src/specs/QuantityTypeModule.nitro.ts +1 -1
- package/src/specs/WorkoutProxy.nitro.ts +3 -16
- package/src/specs/WorkoutsModule.nitro.ts +2 -2
- package/src/types/Device.ts +8 -8
- package/src/types/InterfaceVerificationExample.ts +2 -2
- package/src/types/Source.ts +2 -2
- package/src/types/Subscriptions.ts +19 -1
- package/src/types/Workouts.ts +1 -1
- package/src/utils/subscribeToQuantitySamples.ts +63 -0
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
// Forward declaration of `CategoryTypeIdentifier` to properly resolve imports.
|
|
27
27
|
namespace margelo::nitro::healthkit { enum class CategoryTypeIdentifier; }
|
|
28
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
29
|
-
namespace NitroModules { class AnyMap; }
|
|
30
28
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
31
29
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
32
30
|
|
|
@@ -29,8 +29,6 @@ namespace margelo::nitro::healthkit { enum class CorrelationTypeIdentifier; }
|
|
|
29
29
|
namespace margelo::nitro::healthkit { struct CategorySample; }
|
|
30
30
|
// Forward declaration of `QuantitySample` to properly resolve imports.
|
|
31
31
|
namespace margelo::nitro::healthkit { struct QuantitySample; }
|
|
32
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
33
|
-
namespace NitroModules { class AnyMap; }
|
|
34
32
|
|
|
35
33
|
#include <string>
|
|
36
34
|
#include "CorrelationTypeIdentifier.hpp"
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
namespace NitroModules { class AnyMap; }
|
|
26
|
+
|
|
28
27
|
|
|
29
28
|
#include <string>
|
|
30
29
|
#include <NitroModules/AnyMap.hpp>
|
|
@@ -31,8 +31,6 @@ namespace margelo::nitro::healthkit { enum class ElectrocardiogramClassification
|
|
|
31
31
|
namespace margelo::nitro::healthkit { enum class ElectrocardiogramSymptomsStatus; }
|
|
32
32
|
// Forward declaration of `ElectrocardiogramVoltage` to properly resolve imports.
|
|
33
33
|
namespace margelo::nitro::healthkit { struct ElectrocardiogramVoltage; }
|
|
34
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
35
|
-
namespace NitroModules { class AnyMap; }
|
|
36
34
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
37
35
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
38
36
|
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
namespace margelo::nitro::healthkit { struct Device; }
|
|
28
28
|
// Forward declaration of `Heartbeat` to properly resolve imports.
|
|
29
29
|
namespace margelo::nitro::healthkit { struct Heartbeat; }
|
|
30
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
31
|
-
namespace NitroModules { class AnyMap; }
|
|
32
30
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
33
31
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
34
32
|
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
// Forward declaration of `CategoryTypeIdentifier` to properly resolve imports.
|
|
17
17
|
namespace margelo::nitro::healthkit { enum class CategoryTypeIdentifier; }
|
|
18
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
19
|
-
namespace NitroModules { class AnyMap; }
|
|
20
18
|
// Forward declaration of `CategorySample` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::healthkit { struct CategorySample; }
|
|
22
20
|
// Forward declaration of `QueryOptionsWithSortOrder` to properly resolve imports.
|
|
@@ -31,8 +31,8 @@ namespace margelo::nitro::healthkit { struct OnChangeCallbackArgs; }
|
|
|
31
31
|
namespace margelo::nitro::healthkit { enum class AuthorizationStatus; }
|
|
32
32
|
// Forward declaration of `AuthorizationRequestStatus` to properly resolve imports.
|
|
33
33
|
namespace margelo::nitro::healthkit { enum class AuthorizationRequestStatus; }
|
|
34
|
-
// Forward declaration of `
|
|
35
|
-
namespace margelo::nitro::healthkit {
|
|
34
|
+
// Forward declaration of `AuthDataTypes` to properly resolve imports.
|
|
35
|
+
namespace margelo::nitro::healthkit { struct AuthDataTypes; }
|
|
36
36
|
// Forward declaration of `PredicateWithUUID` to properly resolve imports.
|
|
37
37
|
namespace margelo::nitro::healthkit { struct PredicateWithUUID; }
|
|
38
38
|
// Forward declaration of `PredicateWithUUIDs` to properly resolve imports.
|
|
@@ -63,7 +63,7 @@ namespace margelo::nitro::healthkit { struct FilterForSamplesOr; }
|
|
|
63
63
|
#include <functional>
|
|
64
64
|
#include "AuthorizationStatus.hpp"
|
|
65
65
|
#include "AuthorizationRequestStatus.hpp"
|
|
66
|
-
#include "
|
|
66
|
+
#include "AuthDataTypes.hpp"
|
|
67
67
|
#include "PredicateWithUUID.hpp"
|
|
68
68
|
#include "PredicateWithUUIDs.hpp"
|
|
69
69
|
#include "PredicateWithMetadataKey.hpp"
|
|
@@ -120,8 +120,8 @@ namespace margelo::nitro::healthkit {
|
|
|
120
120
|
virtual double unsubscribeQueries(const std::vector<std::string>& queryIds) = 0;
|
|
121
121
|
virtual std::shared_ptr<Promise<double>> unsubscribeQueriesAsync(const std::vector<std::string>& queryIds) = 0;
|
|
122
122
|
virtual AuthorizationStatus authorizationStatusFor(ObjectTypeIdentifier type) = 0;
|
|
123
|
-
virtual std::shared_ptr<Promise<AuthorizationRequestStatus>> getRequestStatusForAuthorization(const
|
|
124
|
-
virtual std::shared_ptr<Promise<bool>> requestAuthorization(const
|
|
123
|
+
virtual std::shared_ptr<Promise<AuthorizationRequestStatus>> getRequestStatusForAuthorization(const AuthDataTypes& toCheck) = 0;
|
|
124
|
+
virtual std::shared_ptr<Promise<bool>> requestAuthorization(const AuthDataTypes& toRequest) = 0;
|
|
125
125
|
virtual std::shared_ptr<Promise<double>> deleteObjects(ObjectTypeIdentifier objectTypeIdentifier, const std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, FilterForSamplesAnd, FilterForSamplesOr>& filter) = 0;
|
|
126
126
|
virtual bool isObjectTypeAvailable(ObjectTypeIdentifier objectTypeIdentifier) = 0;
|
|
127
127
|
virtual std::unordered_map<std::string, bool> areObjectTypesAvailable(const std::vector<ObjectTypeIdentifier>& objectTypeIdentifiers) = 0;
|
|
@@ -19,8 +19,6 @@ namespace margelo::nitro::healthkit { enum class CorrelationTypeIdentifier; }
|
|
|
19
19
|
namespace margelo::nitro::healthkit { struct CategorySampleForSaving; }
|
|
20
20
|
// Forward declaration of `QuantitySampleForSaving` to properly resolve imports.
|
|
21
21
|
namespace margelo::nitro::healthkit { struct QuantitySampleForSaving; }
|
|
22
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
23
|
-
namespace NitroModules { class AnyMap; }
|
|
24
22
|
// Forward declaration of `CorrelationSample` to properly resolve imports.
|
|
25
23
|
namespace margelo::nitro::healthkit { struct CorrelationSample; }
|
|
26
24
|
|
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
// Forward declaration of `QuantityTypeIdentifier` to properly resolve imports.
|
|
17
17
|
namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
18
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
19
|
-
namespace NitroModules { class AnyMap; }
|
|
20
18
|
// Forward declaration of `PredicateWithUUID` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::healthkit { struct PredicateWithUUID; }
|
|
22
20
|
// Forward declaration of `PredicateWithUUIDs` to properly resolve imports.
|
|
@@ -108,7 +106,7 @@ namespace margelo::nitro::healthkit {
|
|
|
108
106
|
virtual std::shared_ptr<Promise<bool>> deleteQuantitySamples(QuantityTypeIdentifier identifier, const std::variant<PredicateWithUUID, PredicateWithUUIDs, PredicateWithMetadataKey, PredicateWithStartAndEnd, PredicateFromWorkout, FilterForSamplesAnd, FilterForSamplesOr>& filter) = 0;
|
|
109
107
|
virtual std::shared_ptr<Promise<std::vector<QuantitySample>>> queryQuantitySamples(QuantityTypeIdentifier identifier, const std::optional<QueryOptionsWithSortOrderAndUnit>& options) = 0;
|
|
110
108
|
virtual std::shared_ptr<Promise<QueryStatisticsResponse>> queryStatisticsForQuantity(QuantityTypeIdentifier identifier, const std::vector<StatisticsOptions>& statistics, const std::optional<StatisticsQueryOptions>& options) = 0;
|
|
111
|
-
virtual std::shared_ptr<Promise<std::vector<QueryStatisticsResponse>>> queryStatisticsCollectionForQuantity(QuantityTypeIdentifier identifier, const std::vector<StatisticsOptions>& statistics,
|
|
109
|
+
virtual std::shared_ptr<Promise<std::vector<QueryStatisticsResponse>>> queryStatisticsCollectionForQuantity(QuantityTypeIdentifier identifier, const std::vector<StatisticsOptions>& statistics, std::chrono::system_clock::time_point anchorDate, const IntervalComponents& intervalComponents, const std::optional<StatisticsQueryOptions>& options) = 0;
|
|
112
110
|
virtual std::shared_ptr<Promise<QuantitySamplesWithAnchorResponse>> queryQuantitySamplesWithAnchor(QuantityTypeIdentifier identifier, const QueryOptionsWithAnchorAndUnit& options) = 0;
|
|
113
111
|
|
|
114
112
|
protected:
|
|
@@ -23,8 +23,6 @@ namespace margelo::nitro::healthkit { enum class StateOfMindKind; }
|
|
|
23
23
|
namespace margelo::nitro::healthkit { enum class StateOfMindLabel; }
|
|
24
24
|
// Forward declaration of `StateOfMindAssociation` to properly resolve imports.
|
|
25
25
|
namespace margelo::nitro::healthkit { enum class StateOfMindAssociation; }
|
|
26
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
27
|
-
namespace NitroModules { class AnyMap; }
|
|
28
26
|
|
|
29
27
|
#include "StateOfMindSample.hpp"
|
|
30
28
|
#include <vector>
|
|
@@ -14,10 +14,6 @@ namespace margelo::nitro::healthkit {
|
|
|
14
14
|
HybridObject::loadHybridMethods();
|
|
15
15
|
// load custom methods/properties
|
|
16
16
|
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
-
prototype.registerHybridGetter("totalDistance", &HybridWorkoutProxySpec::getTotalDistance);
|
|
18
|
-
prototype.registerHybridGetter("totalEnergyBurned", &HybridWorkoutProxySpec::getTotalEnergyBurned);
|
|
19
|
-
prototype.registerHybridGetter("totalSwimmingStrokeCount", &HybridWorkoutProxySpec::getTotalSwimmingStrokeCount);
|
|
20
|
-
prototype.registerHybridGetter("totalFlightsClimbed", &HybridWorkoutProxySpec::getTotalFlightsClimbed);
|
|
21
17
|
prototype.registerHybridGetter("uuid", &HybridWorkoutProxySpec::getUuid);
|
|
22
18
|
prototype.registerHybridGetter("device", &HybridWorkoutProxySpec::getDevice);
|
|
23
19
|
prototype.registerHybridGetter("workoutActivityType", &HybridWorkoutProxySpec::getWorkoutActivityType);
|
|
@@ -13,14 +13,12 @@
|
|
|
13
13
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
14
|
#endif
|
|
15
15
|
|
|
16
|
-
// Forward declaration of `Quantity` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::healthkit { struct Quantity; }
|
|
18
16
|
// Forward declaration of `Device` to properly resolve imports.
|
|
19
17
|
namespace margelo::nitro::healthkit { struct Device; }
|
|
20
18
|
// Forward declaration of `WorkoutActivityType` to properly resolve imports.
|
|
21
19
|
namespace margelo::nitro::healthkit { enum class WorkoutActivityType; }
|
|
22
|
-
// Forward declaration of `
|
|
23
|
-
namespace
|
|
20
|
+
// Forward declaration of `Quantity` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::healthkit { struct Quantity; }
|
|
24
22
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
25
23
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
26
24
|
// Forward declaration of `WorkoutEvent` to properly resolve imports.
|
|
@@ -40,11 +38,11 @@ namespace margelo::nitro::healthkit { struct QueryStatisticsResponse; }
|
|
|
40
38
|
// Forward declaration of `QuantityTypeIdentifier` to properly resolve imports.
|
|
41
39
|
namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
42
40
|
|
|
43
|
-
#include "Quantity.hpp"
|
|
44
|
-
#include <optional>
|
|
45
41
|
#include <string>
|
|
46
42
|
#include "Device.hpp"
|
|
43
|
+
#include <optional>
|
|
47
44
|
#include "WorkoutActivityType.hpp"
|
|
45
|
+
#include "Quantity.hpp"
|
|
48
46
|
#include <chrono>
|
|
49
47
|
#include <NitroModules/AnyMap.hpp>
|
|
50
48
|
#include "SourceRevision.hpp"
|
|
@@ -87,10 +85,6 @@ namespace margelo::nitro::healthkit {
|
|
|
87
85
|
|
|
88
86
|
public:
|
|
89
87
|
// Properties
|
|
90
|
-
virtual std::optional<Quantity> getTotalDistance() = 0;
|
|
91
|
-
virtual std::optional<Quantity> getTotalEnergyBurned() = 0;
|
|
92
|
-
virtual std::optional<Quantity> getTotalSwimmingStrokeCount() = 0;
|
|
93
|
-
virtual std::optional<Quantity> getTotalFlightsClimbed() = 0;
|
|
94
88
|
virtual std::string getUuid() = 0;
|
|
95
89
|
virtual std::optional<Device> getDevice() = 0;
|
|
96
90
|
virtual WorkoutActivityType getWorkoutActivityType() = 0;
|
|
@@ -21,8 +21,6 @@ namespace margelo::nitro::healthkit { enum class WorkoutActivityType; }
|
|
|
21
21
|
namespace margelo::nitro::healthkit { struct QuantitySampleForSaving; }
|
|
22
22
|
// Forward declaration of `WorkoutTotals` to properly resolve imports.
|
|
23
23
|
namespace margelo::nitro::healthkit { struct WorkoutTotals; }
|
|
24
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
25
|
-
namespace NitroModules { class AnyMap; }
|
|
26
24
|
// Forward declaration of `QueryWorkoutSamplesWithAnchorResponse` to properly resolve imports.
|
|
27
25
|
namespace margelo::nitro::healthkit { struct QueryWorkoutSamplesWithAnchorResponse; }
|
|
28
26
|
// Forward declaration of `WorkoutQueryOptionsWithAnchor` to properly resolve imports.
|
|
@@ -40,6 +38,7 @@ namespace margelo::nitro::healthkit { struct WorkoutConfiguration; }
|
|
|
40
38
|
#include <vector>
|
|
41
39
|
#include <chrono>
|
|
42
40
|
#include "WorkoutTotals.hpp"
|
|
41
|
+
#include <optional>
|
|
43
42
|
#include <NitroModules/AnyMap.hpp>
|
|
44
43
|
#include "QueryWorkoutSamplesWithAnchorResponse.hpp"
|
|
45
44
|
#include "WorkoutQueryOptionsWithAnchor.hpp"
|
|
@@ -77,7 +76,7 @@ namespace margelo::nitro::healthkit {
|
|
|
77
76
|
|
|
78
77
|
public:
|
|
79
78
|
// Methods
|
|
80
|
-
virtual std::shared_ptr<Promise<std::shared_ptr<HybridWorkoutProxySpec>>> saveWorkoutSample(WorkoutActivityType workoutActivityType, const std::vector<QuantitySampleForSaving>& quantities, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate, const WorkoutTotals
|
|
79
|
+
virtual std::shared_ptr<Promise<std::shared_ptr<HybridWorkoutProxySpec>>> saveWorkoutSample(WorkoutActivityType workoutActivityType, const std::vector<QuantitySampleForSaving>& quantities, std::chrono::system_clock::time_point startDate, std::chrono::system_clock::time_point endDate, const std::optional<WorkoutTotals>& totals, const std::optional<std::shared_ptr<AnyMap>>& metadata) = 0;
|
|
81
80
|
virtual std::shared_ptr<Promise<QueryWorkoutSamplesWithAnchorResponse>> queryWorkoutSamplesWithAnchor(const WorkoutQueryOptionsWithAnchor& options) = 0;
|
|
82
81
|
virtual std::shared_ptr<Promise<std::vector<std::shared_ptr<HybridWorkoutProxySpec>>>> queryWorkoutSamples(const WorkoutQueryOptions& options) = 0;
|
|
83
82
|
virtual std::shared_ptr<Promise<bool>> startWatchAppWithWorkoutConfiguration(const WorkoutConfiguration& workoutConfiguration) = 0;
|
|
@@ -41,11 +41,11 @@ namespace margelo::nitro::healthkit {
|
|
|
41
41
|
public:
|
|
42
42
|
std::string withMetadataKey SWIFT_PRIVATE;
|
|
43
43
|
std::optional<PredicateWithMetadataOperator> operatorType SWIFT_PRIVATE;
|
|
44
|
-
std::optional<std::variant<std::string, double,
|
|
44
|
+
std::optional<std::variant<bool, std::string, double, std::chrono::system_clock::time_point>> value SWIFT_PRIVATE;
|
|
45
45
|
|
|
46
46
|
public:
|
|
47
47
|
PredicateWithMetadataKey() = default;
|
|
48
|
-
explicit PredicateWithMetadataKey(std::string withMetadataKey, std::optional<PredicateWithMetadataOperator> operatorType, std::optional<std::variant<std::string, double,
|
|
48
|
+
explicit PredicateWithMetadataKey(std::string withMetadataKey, std::optional<PredicateWithMetadataOperator> operatorType, std::optional<std::variant<bool, std::string, double, std::chrono::system_clock::time_point>> value): withMetadataKey(withMetadataKey), operatorType(operatorType), value(value) {}
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
} // namespace margelo::nitro::healthkit
|
|
@@ -60,14 +60,14 @@ namespace margelo::nitro {
|
|
|
60
60
|
return margelo::nitro::healthkit::PredicateWithMetadataKey(
|
|
61
61
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "withMetadataKey")),
|
|
62
62
|
JSIConverter<std::optional<margelo::nitro::healthkit::PredicateWithMetadataOperator>>::fromJSI(runtime, obj.getProperty(runtime, "operatorType")),
|
|
63
|
-
JSIConverter<std::optional<std::variant<std::string, double,
|
|
63
|
+
JSIConverter<std::optional<std::variant<bool, std::string, double, std::chrono::system_clock::time_point>>>::fromJSI(runtime, obj.getProperty(runtime, "value"))
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::healthkit::PredicateWithMetadataKey& arg) {
|
|
67
67
|
jsi::Object obj(runtime);
|
|
68
68
|
obj.setProperty(runtime, "withMetadataKey", JSIConverter<std::string>::toJSI(runtime, arg.withMetadataKey));
|
|
69
69
|
obj.setProperty(runtime, "operatorType", JSIConverter<std::optional<margelo::nitro::healthkit::PredicateWithMetadataOperator>>::toJSI(runtime, arg.operatorType));
|
|
70
|
-
obj.setProperty(runtime, "value", JSIConverter<std::optional<std::variant<std::string, double,
|
|
70
|
+
obj.setProperty(runtime, "value", JSIConverter<std::optional<std::variant<bool, std::string, double, std::chrono::system_clock::time_point>>>::toJSI(runtime, arg.value));
|
|
71
71
|
return obj;
|
|
72
72
|
}
|
|
73
73
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -80,7 +80,7 @@ namespace margelo::nitro {
|
|
|
80
80
|
}
|
|
81
81
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "withMetadataKey"))) return false;
|
|
82
82
|
if (!JSIConverter<std::optional<margelo::nitro::healthkit::PredicateWithMetadataOperator>>::canConvert(runtime, obj.getProperty(runtime, "operatorType"))) return false;
|
|
83
|
-
if (!JSIConverter<std::optional<std::variant<std::string, double,
|
|
83
|
+
if (!JSIConverter<std::optional<std::variant<bool, std::string, double, std::chrono::system_clock::time_point>>>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
|
|
84
84
|
return true;
|
|
85
85
|
}
|
|
86
86
|
};
|
|
@@ -27,8 +27,6 @@
|
|
|
27
27
|
namespace margelo::nitro::healthkit { struct Device; }
|
|
28
28
|
// Forward declaration of `QuantityTypeIdentifier` to properly resolve imports.
|
|
29
29
|
namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
30
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
31
|
-
namespace NitroModules { class AnyMap; }
|
|
32
30
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
33
31
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
34
32
|
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
// Forward declaration of `QuantityTypeIdentifier` to properly resolve imports.
|
|
27
27
|
namespace margelo::nitro::healthkit { enum class QuantityTypeIdentifier; }
|
|
28
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
29
|
-
namespace NitroModules { class AnyMap; }
|
|
30
28
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
31
29
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
32
30
|
|
|
@@ -25,8 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
// Forward declaration of `Device` to properly resolve imports.
|
|
27
27
|
namespace margelo::nitro::healthkit { struct Device; }
|
|
28
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
29
|
-
namespace NitroModules { class AnyMap; }
|
|
30
28
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
31
29
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
32
30
|
// Forward declaration of `StateOfMindKind` to properly resolve imports.
|
|
@@ -29,8 +29,6 @@ namespace margelo::nitro::healthkit { struct Device; }
|
|
|
29
29
|
namespace margelo::nitro::healthkit { enum class WorkoutActivityType; }
|
|
30
30
|
// Forward declaration of `Quantity` to properly resolve imports.
|
|
31
31
|
namespace margelo::nitro::healthkit { struct Quantity; }
|
|
32
|
-
// Forward declaration of `AnyMap` to properly resolve imports.
|
|
33
|
-
namespace NitroModules { class AnyMap; }
|
|
34
32
|
// Forward declaration of `SourceRevision` to properly resolve imports.
|
|
35
33
|
namespace margelo::nitro::healthkit { struct SourceRevision; }
|
|
36
34
|
// Forward declaration of `WorkoutEvent` to properly resolve imports.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kingstinct/react-native-healthkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "React Native bindings for HealthKit",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -90,15 +90,15 @@
|
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@testing-library/react-native": "^13.3.3",
|
|
92
92
|
"@types/react": "~19.0.14",
|
|
93
|
-
"nitrogen": "^0.
|
|
93
|
+
"nitrogen": "^0.31.6¨",
|
|
94
94
|
"react": "19.1.0",
|
|
95
|
-
"react-native": "0.81.
|
|
96
|
-
"react-native-nitro-modules": "^0.
|
|
95
|
+
"react-native": "0.81.5",
|
|
96
|
+
"react-native-nitro-modules": "^0.31.6",
|
|
97
97
|
"typescript": "~5.9.3"
|
|
98
98
|
},
|
|
99
99
|
"peerDependencies": {
|
|
100
|
-
"react": "19
|
|
101
|
-
"react-native": "0.
|
|
102
|
-
"react-native-nitro-modules": "0.30
|
|
100
|
+
"react": ">=19",
|
|
101
|
+
"react-native": ">=0.79",
|
|
102
|
+
"react-native-nitro-modules": ">=0.30"
|
|
103
103
|
}
|
|
104
104
|
}
|
package/src/healthkit.ios.ts
CHANGED
|
@@ -7,6 +7,7 @@ import useMostRecentWorkout from './hooks/useMostRecentWorkout'
|
|
|
7
7
|
import useSources from './hooks/useSources'
|
|
8
8
|
import useStatisticsForQuantity from './hooks/useStatisticsForQuantity'
|
|
9
9
|
import useSubscribeToChanges from './hooks/useSubscribeToChanges'
|
|
10
|
+
import useSubscribeToQuantitySamples from './hooks/useSubscribeToQuantitySamples'
|
|
10
11
|
import {
|
|
11
12
|
CategoryTypes,
|
|
12
13
|
Characteristics,
|
|
@@ -23,6 +24,8 @@ import getMostRecentCategorySample from './utils/getMostRecentCategorySample'
|
|
|
23
24
|
import getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'
|
|
24
25
|
import getMostRecentWorkout from './utils/getMostRecentWorkout'
|
|
25
26
|
import getPreferredUnit from './utils/getPreferredUnit'
|
|
27
|
+
import { subscribeToChanges } from './utils/subscribeToChanges'
|
|
28
|
+
import { subscribeToQuantitySamples } from './utils/subscribeToQuantitySamples'
|
|
26
29
|
|
|
27
30
|
export * from './types'
|
|
28
31
|
|
|
@@ -53,14 +56,17 @@ export {
|
|
|
53
56
|
getMostRecentQuantitySample,
|
|
54
57
|
getMostRecentWorkout,
|
|
55
58
|
getPreferredUnit,
|
|
59
|
+
subscribeToChanges,
|
|
60
|
+
subscribeToQuantitySamples,
|
|
61
|
+
useHealthkitAuthorization,
|
|
62
|
+
useIsHealthDataAvailable,
|
|
56
63
|
useMostRecentCategorySample,
|
|
57
64
|
useMostRecentQuantitySample,
|
|
58
65
|
useMostRecentWorkout,
|
|
59
|
-
useSubscribeToChanges,
|
|
60
|
-
useHealthkitAuthorization,
|
|
61
|
-
useIsHealthDataAvailable,
|
|
62
66
|
useSources,
|
|
63
67
|
useStatisticsForQuantity,
|
|
68
|
+
useSubscribeToChanges,
|
|
69
|
+
useSubscribeToQuantitySamples,
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
/**
|
|
@@ -138,7 +144,6 @@ export const saveCorrelationSample =
|
|
|
138
144
|
export const saveQuantitySample =
|
|
139
145
|
QuantityTypes.saveQuantitySample.bind(QuantityTypes)
|
|
140
146
|
export const saveWorkoutSample = Workouts.saveWorkoutSample.bind(Workouts)
|
|
141
|
-
export const subscribeToChanges = Core.subscribeToObserverQuery.bind(Core)
|
|
142
147
|
export const startWatchApp =
|
|
143
148
|
Workouts.startWatchAppWithWorkoutConfiguration.bind(Workouts)
|
|
144
149
|
export const isProtectedDataAvailable = Core.isProtectedDataAvailable.bind(Core)
|
|
@@ -148,7 +153,6 @@ export const saveStateOfMindSample =
|
|
|
148
153
|
StateOfMind.saveStateOfMindSample.bind(StateOfMind)
|
|
149
154
|
export const isQuantityCompatibleWithUnit =
|
|
150
155
|
QuantityTypes.isQuantityCompatibleWithUnit.bind(QuantityTypes)
|
|
151
|
-
export const unsubscribeQueries = Core.unsubscribeQueries.bind(Core)
|
|
152
156
|
|
|
153
157
|
export const isObjectTypeAvailable = Core.isObjectTypeAvailable.bind(Core)
|
|
154
158
|
export const isObjectTypeAvailableAsync =
|
|
@@ -217,7 +221,7 @@ export default {
|
|
|
217
221
|
saveQuantitySample,
|
|
218
222
|
saveWorkoutSample,
|
|
219
223
|
subscribeToChanges,
|
|
220
|
-
|
|
224
|
+
subscribeToQuantitySamples,
|
|
221
225
|
startWatchApp,
|
|
222
226
|
isProtectedDataAvailable,
|
|
223
227
|
queryStateOfMindSamples,
|
|
@@ -228,6 +232,7 @@ export default {
|
|
|
228
232
|
useMostRecentQuantitySample,
|
|
229
233
|
useMostRecentWorkout,
|
|
230
234
|
useSubscribeToChanges,
|
|
235
|
+
useSubscribeToQuantitySamples,
|
|
231
236
|
useHealthkitAuthorization,
|
|
232
237
|
useIsHealthDataAvailable,
|
|
233
238
|
useSources,
|
package/src/healthkit.ts
CHANGED
|
@@ -97,7 +97,9 @@ export const deleteObjects = UnavailableFnFromModule(
|
|
|
97
97
|
)
|
|
98
98
|
export const subscribeToChanges = UnavailableFnFromModule(
|
|
99
99
|
'subscribeToChanges',
|
|
100
|
-
|
|
100
|
+
{
|
|
101
|
+
remove: () => false,
|
|
102
|
+
},
|
|
101
103
|
) // Mocking the observer query UUID
|
|
102
104
|
export const isProtectedDataAvailable = UnavailableFnFromModule(
|
|
103
105
|
'isProtectedDataAvailable',
|
|
@@ -363,18 +365,27 @@ export const getWheelchairUseAsync = UnavailableFnFromModule(
|
|
|
363
365
|
Promise.resolve(WheelchairUse.notSet),
|
|
364
366
|
)
|
|
365
367
|
|
|
366
|
-
|
|
367
|
-
'
|
|
368
|
-
|
|
369
|
-
)
|
|
368
|
+
const subscribeToQuantitySamples = UnavailableFnFromModule(
|
|
369
|
+
'subscribeToQuantitySamples',
|
|
370
|
+
{
|
|
371
|
+
remove: () => false,
|
|
372
|
+
},
|
|
373
|
+
) // Mocking the observer query UUID
|
|
374
|
+
|
|
375
|
+
export { subscribeToQuantitySamples }
|
|
376
|
+
|
|
377
|
+
const useSubscribeToQuantitySamples = UnavailableFnFromModule(
|
|
378
|
+
'useSubscribeToQuantitySamples',
|
|
379
|
+
undefined,
|
|
380
|
+
) // Mocking callback structure
|
|
370
381
|
|
|
382
|
+
export { useSubscribeToQuantitySamples }
|
|
371
383
|
// --- Default Export ---
|
|
372
384
|
// This attempts to match the structure of the default export from index.ios.ts
|
|
373
385
|
const HealthkitModule = {
|
|
374
386
|
// All named exports are also part of the default export object
|
|
375
387
|
authorizationStatusFor,
|
|
376
388
|
isObjectTypeAvailable,
|
|
377
|
-
unsubscribeQueries,
|
|
378
389
|
isObjectTypeAvailableAsync,
|
|
379
390
|
areObjectTypesAvailable,
|
|
380
391
|
areObjectTypesAvailableAsync,
|
|
@@ -420,6 +431,8 @@ const HealthkitModule = {
|
|
|
420
431
|
isProtectedDataAvailable,
|
|
421
432
|
queryStateOfMindSamples,
|
|
422
433
|
saveStateOfMindSample,
|
|
434
|
+
subscribeToQuantitySamples,
|
|
435
|
+
useSubscribeToQuantitySamples,
|
|
423
436
|
|
|
424
437
|
// Hooks
|
|
425
438
|
useMostRecentCategorySample,
|
|
@@ -23,7 +23,9 @@ describe('useHealthkitAuthorization', () => {
|
|
|
23
23
|
)
|
|
24
24
|
|
|
25
25
|
const { result } = renderHook(() =>
|
|
26
|
-
useHealthkitAuthorization(
|
|
26
|
+
useHealthkitAuthorization({
|
|
27
|
+
toRead: ['HKCategoryTypeIdentifierAbdominalCramps'],
|
|
28
|
+
}),
|
|
27
29
|
)
|
|
28
30
|
|
|
29
31
|
await waitForNextUpdate()
|
|
@@ -42,7 +44,9 @@ describe('useHealthkitAuthorization', () => {
|
|
|
42
44
|
.mockReturnValue(Promise.resolve(true))
|
|
43
45
|
|
|
44
46
|
const { result } = renderHook(() =>
|
|
45
|
-
useHealthkitAuthorization(
|
|
47
|
+
useHealthkitAuthorization({
|
|
48
|
+
toRead: ['HKCategoryTypeIdentifierAbdominalCramps'],
|
|
49
|
+
}),
|
|
46
50
|
)
|
|
47
51
|
|
|
48
52
|
await waitForNextUpdate()
|
|
@@ -66,7 +70,9 @@ describe('useHealthkitAuthorization', () => {
|
|
|
66
70
|
.mockReturnValue(Promise.resolve(AuthorizationRequestStatus.unnecessary))
|
|
67
71
|
|
|
68
72
|
const { result } = renderHook(() =>
|
|
69
|
-
useHealthkitAuthorization(
|
|
73
|
+
useHealthkitAuthorization({
|
|
74
|
+
toWrite: ['HKCategoryTypeIdentifierAbdominalCramps'],
|
|
75
|
+
}),
|
|
70
76
|
)
|
|
71
77
|
|
|
72
78
|
await waitForNextUpdate()
|
|
@@ -76,7 +82,9 @@ describe('useHealthkitAuthorization', () => {
|
|
|
76
82
|
|
|
77
83
|
test('should return null before initalizing', async () => {
|
|
78
84
|
const { result } = renderHook(() =>
|
|
79
|
-
useHealthkitAuthorization(
|
|
85
|
+
useHealthkitAuthorization({
|
|
86
|
+
toRead: ['HKCategoryTypeIdentifierAbdominalCramps'],
|
|
87
|
+
}),
|
|
80
88
|
)
|
|
81
89
|
|
|
82
90
|
expect(result.current[0]).toBe(null)
|
|
@@ -12,32 +12,38 @@ import type {
|
|
|
12
12
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
13
13
|
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
14
14
|
*/
|
|
15
|
-
export const useHealthkitAuthorization = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
export const useHealthkitAuthorization = ({
|
|
16
|
+
toWrite,
|
|
17
|
+
toRead,
|
|
18
|
+
}: {
|
|
19
|
+
toRead?: readonly ObjectTypeIdentifier[]
|
|
20
|
+
toWrite?: readonly SampleTypeIdentifierWriteable[]
|
|
21
|
+
}) => {
|
|
19
22
|
const [status, setStatus] = useState<AuthorizationRequestStatus | null>(null)
|
|
20
23
|
|
|
21
|
-
const readMemo = useRef(
|
|
22
|
-
const writeMemo = useRef(
|
|
24
|
+
const readMemo = useRef(toRead)
|
|
25
|
+
const writeMemo = useRef(toWrite)
|
|
23
26
|
|
|
24
27
|
useEffect(() => {
|
|
25
|
-
readMemo.current =
|
|
26
|
-
writeMemo.current =
|
|
27
|
-
}, [
|
|
28
|
+
readMemo.current = toRead
|
|
29
|
+
writeMemo.current = toWrite
|
|
30
|
+
}, [toRead, toWrite])
|
|
28
31
|
|
|
29
32
|
const refreshAuthStatus = useCallback(async () => {
|
|
30
|
-
const auth = await Core.getRequestStatusForAuthorization(
|
|
31
|
-
writeMemo.current
|
|
32
|
-
readMemo.current,
|
|
33
|
-
)
|
|
33
|
+
const auth = await Core.getRequestStatusForAuthorization({
|
|
34
|
+
toShare: writeMemo.current,
|
|
35
|
+
toRead: readMemo.current,
|
|
36
|
+
})
|
|
34
37
|
|
|
35
38
|
setStatus(auth)
|
|
36
39
|
return auth
|
|
37
40
|
}, [])
|
|
38
41
|
|
|
39
42
|
const request = useCallback(async () => {
|
|
40
|
-
await Core.requestAuthorization(
|
|
43
|
+
await Core.requestAuthorization({
|
|
44
|
+
toShare: writeMemo.current,
|
|
45
|
+
toRead: readMemo.current,
|
|
46
|
+
})
|
|
41
47
|
return refreshAuthStatus()
|
|
42
48
|
}, [refreshAuthStatus])
|
|
43
49
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
import type {
|
|
3
|
+
OnQuantitySamplesCallback,
|
|
4
|
+
QuantityTypeIdentifier,
|
|
5
|
+
} from '../types'
|
|
6
|
+
import { subscribeToQuantitySamples } from '../utils/subscribeToQuantitySamples'
|
|
7
|
+
|
|
8
|
+
export function useSubscribeToQuantitySamples<
|
|
9
|
+
TIdentifier extends QuantityTypeIdentifier,
|
|
10
|
+
>(
|
|
11
|
+
identifier: TIdentifier,
|
|
12
|
+
onChange: (args: OnQuantitySamplesCallback) => void,
|
|
13
|
+
): void {
|
|
14
|
+
const onChangeRef = useRef(onChange)
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
onChangeRef.current = onChange
|
|
18
|
+
}, [onChange])
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const subscription = subscribeToQuantitySamples(identifier, (args) => {
|
|
22
|
+
onChangeRef.current(args)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
return () => {
|
|
26
|
+
subscription.remove()
|
|
27
|
+
}
|
|
28
|
+
}, [identifier])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default useSubscribeToQuantitySamples
|
|
@@ -40,7 +40,7 @@ export interface CategoryTypeModule extends HybridObject<{ ios: 'swift' }> {
|
|
|
40
40
|
const _interfaceVerification: InterfaceAssertion<
|
|
41
41
|
CategoryTypeModule,
|
|
42
42
|
CategoryTypeModuleTyped,
|
|
43
|
-
keyof HybridObject
|
|
43
|
+
keyof HybridObject<{ ios: 'swift' }>
|
|
44
44
|
> = true
|
|
45
45
|
|
|
46
46
|
export interface CategoryTypeModuleTyped {
|
|
@@ -9,13 +9,13 @@ import type {
|
|
|
9
9
|
export interface CharacteristicTypeModule
|
|
10
10
|
extends HybridObject<{ ios: 'swift' }> {
|
|
11
11
|
getBloodType(): BloodType
|
|
12
|
-
getDateOfBirth(): Date |
|
|
12
|
+
getDateOfBirth(): Date | undefined
|
|
13
13
|
getBiologicalSex(): BiologicalSex
|
|
14
14
|
getFitzpatrickSkinType(): FitzpatrickSkinType
|
|
15
15
|
getWheelchairUse(): WheelchairUse
|
|
16
16
|
|
|
17
17
|
getBloodTypeAsync(): Promise<BloodType>
|
|
18
|
-
getDateOfBirthAsync(): Promise<Date |
|
|
18
|
+
getDateOfBirthAsync(): Promise<Date | undefined>
|
|
19
19
|
getBiologicalSexAsync(): Promise<BiologicalSex>
|
|
20
20
|
getFitzpatrickSkinTypeAsync(): Promise<FitzpatrickSkinType>
|
|
21
21
|
getWheelchairUseAsync(): Promise<WheelchairUse>
|