@gromozeqa/react-native-apple-health-kit 0.1.4 → 0.2.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.
Files changed (45) hide show
  1. package/README.md +14 -3
  2. package/{AppleHealthKit.podspec → ReactNativeAppleHealthKit.podspec} +1 -1
  3. package/android/generated/java/com/{applehealthkit/NativeAppleHealthKitSpec.java → gromozeqa/reactnativeapplehealthkit/NativeReactNativeAppleHealthKitSpec.java} +4 -4
  4. package/android/generated/jni/CMakeLists.txt +5 -5
  5. package/android/generated/jni/{RNAppleHealthKitSpec-generated.cpp → RNReactNativeAppleHealthKitSpec-generated.cpp} +13 -13
  6. package/android/generated/jni/{RNAppleHealthKitSpec.h → RNReactNativeAppleHealthKitSpec.h} +4 -4
  7. package/android/generated/jni/react/renderer/components/RNReactNativeAppleHealthKitSpec/RNReactNativeAppleHealthKitSpecJSI-generated.cpp +46 -0
  8. package/android/generated/jni/react/renderer/components/{RNAppleHealthKitSpec/RNAppleHealthKitSpecJSI.h → RNReactNativeAppleHealthKitSpec/RNReactNativeAppleHealthKitSpecJSI.h} +69 -21
  9. package/ios/{AppleHealthKitManager.swift → HealthKitManager.swift} +8 -1
  10. package/ios/{AppleHealthKitPermissions.swift → HealthKitPermissions.swift} +8 -1
  11. package/ios/{AppleHealthKitQueries.swift → HealthKitQueries.swift} +8 -0
  12. package/ios/ReactNativeAppleHealthKit.h +6 -0
  13. package/ios/{AppleHealthKit.mm → ReactNativeAppleHealthKit.mm} +8 -8
  14. package/ios/{HealthKitUtils.swift → Utils.swift} +2 -2
  15. package/ios/generated/{RNAppleHealthKitSpec/RNAppleHealthKitSpec-generated.mm → RNReactNativeAppleHealthKitSpec/RNReactNativeAppleHealthKitSpec-generated.mm} +11 -11
  16. package/ios/generated/{RNAppleHealthKitSpec/RNAppleHealthKitSpec.h → RNReactNativeAppleHealthKitSpec/RNReactNativeAppleHealthKitSpec.h} +9 -9
  17. package/ios/generated/RNReactNativeAppleHealthKitSpecJSI-generated.cpp +46 -0
  18. package/ios/generated/{RNAppleHealthKitSpecJSI.h → RNReactNativeAppleHealthKitSpecJSI.h} +69 -21
  19. package/lib/commonjs/{NativeAppleHealthKit.js → NativeReactNativeAppleHealthKit.js} +2 -2
  20. package/lib/commonjs/NativeReactNativeAppleHealthKit.js.map +1 -0
  21. package/lib/commonjs/index.js +16 -11
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/module/{NativeAppleHealthKit.js → NativeReactNativeAppleHealthKit.js} +2 -2
  24. package/lib/module/NativeReactNativeAppleHealthKit.js.map +1 -0
  25. package/lib/module/index.js +13 -7
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/typescript/{module/src/NativeAppleHealthKit.d.ts → commonjs/src/NativeReactNativeAppleHealthKit.d.ts} +6 -5
  28. package/lib/typescript/commonjs/src/NativeReactNativeAppleHealthKit.d.ts.map +1 -0
  29. package/lib/typescript/commonjs/src/index.d.ts +5 -1
  30. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  31. package/lib/typescript/{commonjs/src/NativeAppleHealthKit.d.ts → module/src/NativeReactNativeAppleHealthKit.d.ts} +6 -5
  32. package/lib/typescript/module/src/NativeReactNativeAppleHealthKit.d.ts.map +1 -0
  33. package/lib/typescript/module/src/index.d.ts +5 -1
  34. package/lib/typescript/module/src/index.d.ts.map +1 -1
  35. package/package.json +8 -8
  36. package/react-native.config.js +3 -2
  37. package/src/{NativeAppleHealthKit.ts → NativeReactNativeAppleHealthKit.ts} +7 -5
  38. package/src/index.tsx +23 -8
  39. package/android/generated/jni/react/renderer/components/RNAppleHealthKitSpec/RNAppleHealthKitSpecJSI-generated.cpp +0 -46
  40. package/ios/AppleHealthKit.h +0 -6
  41. package/ios/generated/RNAppleHealthKitSpecJSI-generated.cpp +0 -46
  42. package/lib/commonjs/NativeAppleHealthKit.js.map +0 -1
  43. package/lib/module/NativeAppleHealthKit.js.map +0 -1
  44. package/lib/typescript/commonjs/src/NativeAppleHealthKit.d.ts.map +0 -1
  45. package/lib/typescript/module/src/NativeAppleHealthKit.d.ts.map +0 -1
package/README.md CHANGED
@@ -1,11 +1,22 @@
1
- # react-native-apple-health-kit
1
+ # @gromozeqa/react-native-apple-health-kit
2
2
 
3
- IOS module for Apple Healhkit
3
+ IOS module for react native to enable health kit
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```sh
8
- npm install react-native-apple-health-kit
8
+ npm install @gromozeqa/react-native-apple-health-kit
9
+ ```
10
+
11
+ ## Usage
12
+
13
+
14
+ ```js
15
+ import { multiply } from '@gromozeqa/react-native-apple-health-kit';
16
+
17
+ // ...
18
+
19
+ const result = multiply(3, 7);
9
20
  ```
10
21
 
11
22
 
@@ -4,7 +4,7 @@ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
4
  folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
5
5
 
6
6
  Pod::Spec.new do |s|
7
- s.name = "AppleHealthKit"
7
+ s.name = "ReactNativeAppleHealthKit"
8
8
  s.version = package["version"]
9
9
  s.summary = package["description"]
10
10
  s.homepage = package["homepage"]
@@ -10,7 +10,7 @@
10
10
  * @nolint
11
11
  */
12
12
 
13
- package com.applehealthkit;
13
+ package com.gromozeqa.reactnativeapplehealthkit;
14
14
 
15
15
  import com.facebook.proguard.annotations.DoNotStrip;
16
16
  import com.facebook.react.bridge.Promise;
@@ -20,10 +20,10 @@ import com.facebook.react.bridge.ReactMethod;
20
20
  import com.facebook.react.turbomodule.core.interfaces.TurboModule;
21
21
  import javax.annotation.Nonnull;
22
22
 
23
- public abstract class NativeAppleHealthKitSpec extends ReactContextBaseJavaModule implements TurboModule {
24
- public static final String NAME = "AppleHealthKit";
23
+ public abstract class NativeReactNativeAppleHealthKitSpec extends ReactContextBaseJavaModule implements TurboModule {
24
+ public static final String NAME = "ReactNativeAppleHealthKit";
25
25
 
26
- public NativeAppleHealthKitSpec(ReactApplicationContext reactContext) {
26
+ public NativeReactNativeAppleHealthKitSpec(ReactApplicationContext reactContext) {
27
27
  super(reactContext);
28
28
  }
29
29
 
@@ -6,18 +6,18 @@
6
6
  cmake_minimum_required(VERSION 3.13)
7
7
  set(CMAKE_VERBOSE_MAKEFILE on)
8
8
 
9
- file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNAppleHealthKitSpec/*.cpp)
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/RNReactNativeAppleHealthKitSpec/*.cpp)
10
10
 
11
11
  add_library(
12
- react_codegen_RNAppleHealthKitSpec
12
+ react_codegen_RNReactNativeAppleHealthKitSpec
13
13
  OBJECT
14
14
  ${react_codegen_SRCS}
15
15
  )
16
16
 
17
- target_include_directories(react_codegen_RNAppleHealthKitSpec PUBLIC . react/renderer/components/RNAppleHealthKitSpec)
17
+ target_include_directories(react_codegen_RNReactNativeAppleHealthKitSpec PUBLIC . react/renderer/components/RNReactNativeAppleHealthKitSpec)
18
18
 
19
19
  target_link_libraries(
20
- react_codegen_RNAppleHealthKitSpec
20
+ react_codegen_RNReactNativeAppleHealthKitSpec
21
21
  fbjni
22
22
  jsi
23
23
  # We need to link different libraries based on whether we are building rncore or not, that's necessary
@@ -26,7 +26,7 @@ target_link_libraries(
26
26
  )
27
27
 
28
28
  target_compile_options(
29
- react_codegen_RNAppleHealthKitSpec
29
+ react_codegen_RNReactNativeAppleHealthKitSpec
30
30
  PRIVATE
31
31
  -DLOG_TAG=\"ReactNative\"
32
32
  -fexceptions
@@ -8,41 +8,41 @@
8
8
  * @generated by codegen project: GenerateModuleJniCpp.js
9
9
  */
10
10
 
11
- #include "RNAppleHealthKitSpec.h"
11
+ #include "RNReactNativeAppleHealthKitSpec.h"
12
12
 
13
13
  namespace facebook::react {
14
14
 
15
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
15
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_requestHealthKitPermissions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16
16
  static jmethodID cachedMethodId = nullptr;
17
17
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "requestHealthKitPermissions", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
18
18
  }
19
19
 
20
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getSteps(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
20
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getSteps(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21
21
  static jmethodID cachedMethodId = nullptr;
22
22
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getSteps", "(DLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
23
23
  }
24
24
 
25
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
25
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getHeartRate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26
26
  static jmethodID cachedMethodId = nullptr;
27
27
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getHeartRate", "(DLcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
28
28
  }
29
29
 
30
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
30
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getMeasurement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
31
31
  static jmethodID cachedMethodId = nullptr;
32
32
  return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getMeasurement", "(Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
33
33
  }
34
34
 
35
- NativeAppleHealthKitSpecJSI::NativeAppleHealthKitSpecJSI(const JavaTurboModule::InitParams &params)
35
+ NativeReactNativeAppleHealthKitSpecJSI::NativeReactNativeAppleHealthKitSpecJSI(const JavaTurboModule::InitParams &params)
36
36
  : JavaTurboModule(params) {
37
- methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions};
38
- methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getSteps};
39
- methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate};
40
- methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement};
37
+ methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_requestHealthKitPermissions};
38
+ methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getSteps};
39
+ methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getHeartRate};
40
+ methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getMeasurement};
41
41
  }
42
42
 
43
- std::shared_ptr<TurboModule> RNAppleHealthKitSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
44
- if (moduleName == "AppleHealthKit") {
45
- return std::make_shared<NativeAppleHealthKitSpecJSI>(params);
43
+ std::shared_ptr<TurboModule> RNReactNativeAppleHealthKitSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
44
+ if (moduleName == "ReactNativeAppleHealthKit") {
45
+ return std::make_shared<NativeReactNativeAppleHealthKitSpecJSI>(params);
46
46
  }
47
47
  return nullptr;
48
48
  }
@@ -17,15 +17,15 @@
17
17
  namespace facebook::react {
18
18
 
19
19
  /**
20
- * JNI C++ class for module 'NativeAppleHealthKit'
20
+ * JNI C++ class for module 'NativeReactNativeAppleHealthKit'
21
21
  */
22
- class JSI_EXPORT NativeAppleHealthKitSpecJSI : public JavaTurboModule {
22
+ class JSI_EXPORT NativeReactNativeAppleHealthKitSpecJSI : public JavaTurboModule {
23
23
  public:
24
- NativeAppleHealthKitSpecJSI(const JavaTurboModule::InitParams &params);
24
+ NativeReactNativeAppleHealthKitSpecJSI(const JavaTurboModule::InitParams &params);
25
25
  };
26
26
 
27
27
 
28
28
  JSI_EXPORT
29
- std::shared_ptr<TurboModule> RNAppleHealthKitSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
29
+ std::shared_ptr<TurboModule> RNReactNativeAppleHealthKitSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30
30
 
31
31
  } // namespace facebook::react
@@ -0,0 +1,46 @@
1
+ /**
2
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
+ *
4
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNReactNativeAppleHealthKitSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_requestHealthKitPermissions(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeReactNativeAppleHealthKitCxxSpecJSI *>(&turboModule)->requestHealthKitPermissions(
16
+ rt
17
+ );
18
+ }
19
+ static jsi::Value __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getSteps(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
20
+ return static_cast<NativeReactNativeAppleHealthKitCxxSpecJSI *>(&turboModule)->getSteps(
21
+ rt,
22
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
23
+ );
24
+ }
25
+ static jsi::Value __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getHeartRate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
26
+ return static_cast<NativeReactNativeAppleHealthKitCxxSpecJSI *>(&turboModule)->getHeartRate(
27
+ rt,
28
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber()
29
+ );
30
+ }
31
+ static jsi::Value __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getMeasurement(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
32
+ return static_cast<NativeReactNativeAppleHealthKitCxxSpecJSI *>(&turboModule)->getMeasurement(
33
+ rt
34
+ );
35
+ }
36
+
37
+ NativeReactNativeAppleHealthKitCxxSpecJSI::NativeReactNativeAppleHealthKitCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
38
+ : TurboModule("ReactNativeAppleHealthKit", jsInvoker) {
39
+ methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_requestHealthKitPermissions};
40
+ methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getSteps};
41
+ methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getHeartRate};
42
+ methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitCxxSpecJSI_getMeasurement};
43
+ }
44
+
45
+
46
+ } // namespace facebook::react
@@ -16,19 +16,19 @@ namespace facebook::react {
16
16
 
17
17
 
18
18
 
19
- #pragma mark - NativeAppleHealthKitHeartRate
19
+ #pragma mark - NativeReactNativeAppleHealthKitHeartRate
20
20
 
21
21
  template <typename P0, typename P1>
22
- struct NativeAppleHealthKitHeartRate {
22
+ struct NativeReactNativeAppleHealthKitHeartRate {
23
23
  P0 date;
24
24
  P1 value;
25
- bool operator==(const NativeAppleHealthKitHeartRate &other) const {
25
+ bool operator==(const NativeReactNativeAppleHealthKitHeartRate &other) const {
26
26
  return date == other.date && value == other.value;
27
27
  }
28
28
  };
29
29
 
30
30
  template <typename T>
31
- struct NativeAppleHealthKitHeartRateBridging {
31
+ struct NativeReactNativeAppleHealthKitHeartRateBridging {
32
32
  static T types;
33
33
 
34
34
  static T fromJs(
@@ -64,21 +64,69 @@ struct NativeAppleHealthKitHeartRateBridging {
64
64
 
65
65
 
66
66
 
67
- #pragma mark - NativeAppleHealthKitMeasurement
67
+ #pragma mark - NativeReactNativeAppleHealthKitHeartRateValue
68
+
69
+ template <typename P0, typename P1>
70
+ struct NativeReactNativeAppleHealthKitHeartRateValue {
71
+ P0 time;
72
+ P1 heartRate;
73
+ bool operator==(const NativeReactNativeAppleHealthKitHeartRateValue &other) const {
74
+ return time == other.time && heartRate == other.heartRate;
75
+ }
76
+ };
77
+
78
+ template <typename T>
79
+ struct NativeReactNativeAppleHealthKitHeartRateValueBridging {
80
+ static T types;
81
+
82
+ static T fromJs(
83
+ jsi::Runtime &rt,
84
+ const jsi::Object &value,
85
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
86
+ T result{
87
+ bridging::fromJs<decltype(types.time)>(rt, value.getProperty(rt, "time"), jsInvoker),
88
+ bridging::fromJs<decltype(types.heartRate)>(rt, value.getProperty(rt, "heartRate"), jsInvoker)};
89
+ return result;
90
+ }
91
+
92
+ #ifdef DEBUG
93
+ static jsi::String timeToJs(jsi::Runtime &rt, decltype(types.time) value) {
94
+ return bridging::toJs(rt, value);
95
+ }
96
+
97
+ static double heartRateToJs(jsi::Runtime &rt, decltype(types.heartRate) value) {
98
+ return bridging::toJs(rt, value);
99
+ }
100
+ #endif
101
+
102
+ static jsi::Object toJs(
103
+ jsi::Runtime &rt,
104
+ const T &value,
105
+ const std::shared_ptr<CallInvoker> &jsInvoker) {
106
+ auto result = facebook::jsi::Object(rt);
107
+ result.setProperty(rt, "time", bridging::toJs(rt, value.time, jsInvoker));
108
+ result.setProperty(rt, "heartRate", bridging::toJs(rt, value.heartRate, jsInvoker));
109
+ return result;
110
+ }
111
+ };
112
+
113
+
114
+
115
+ #pragma mark - NativeReactNativeAppleHealthKitMeasurement
68
116
 
69
117
  template <typename P0, typename P1, typename P2, typename P3>
70
- struct NativeAppleHealthKitMeasurement {
118
+ struct NativeReactNativeAppleHealthKitMeasurement {
71
119
  P0 bodyMass;
72
120
  P1 height;
73
121
  P2 biologicalSex;
74
122
  P3 dateOfBirth;
75
- bool operator==(const NativeAppleHealthKitMeasurement &other) const {
123
+ bool operator==(const NativeReactNativeAppleHealthKitMeasurement &other) const {
76
124
  return bodyMass == other.bodyMass && height == other.height && biologicalSex == other.biologicalSex && dateOfBirth == other.dateOfBirth;
77
125
  }
78
126
  };
79
127
 
80
128
  template <typename T>
81
- struct NativeAppleHealthKitMeasurementBridging {
129
+ struct NativeReactNativeAppleHealthKitMeasurementBridging {
82
130
  static T types;
83
131
 
84
132
  static T fromJs(
@@ -126,19 +174,19 @@ struct NativeAppleHealthKitMeasurementBridging {
126
174
 
127
175
 
128
176
 
129
- #pragma mark - NativeAppleHealthKitStep
177
+ #pragma mark - NativeReactNativeAppleHealthKitStep
130
178
 
131
179
  template <typename P0, typename P1>
132
- struct NativeAppleHealthKitStep {
180
+ struct NativeReactNativeAppleHealthKitStep {
133
181
  P0 dateString;
134
182
  P1 stepCount;
135
- bool operator==(const NativeAppleHealthKitStep &other) const {
183
+ bool operator==(const NativeReactNativeAppleHealthKitStep &other) const {
136
184
  return dateString == other.dateString && stepCount == other.stepCount;
137
185
  }
138
186
  };
139
187
 
140
188
  template <typename T>
141
- struct NativeAppleHealthKitStepBridging {
189
+ struct NativeReactNativeAppleHealthKitStepBridging {
142
190
  static T types;
143
191
 
144
192
  static T fromJs(
@@ -172,9 +220,9 @@ struct NativeAppleHealthKitStepBridging {
172
220
  }
173
221
  };
174
222
 
175
- class JSI_EXPORT NativeAppleHealthKitCxxSpecJSI : public TurboModule {
223
+ class JSI_EXPORT NativeReactNativeAppleHealthKitCxxSpecJSI : public TurboModule {
176
224
  protected:
177
- NativeAppleHealthKitCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
225
+ NativeReactNativeAppleHealthKitCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
178
226
 
179
227
  public:
180
228
  virtual jsi::Value requestHealthKitPermissions(jsi::Runtime &rt) = 0;
@@ -185,7 +233,7 @@ public:
185
233
  };
186
234
 
187
235
  template <typename T>
188
- class JSI_EXPORT NativeAppleHealthKitCxxSpec : public TurboModule {
236
+ class JSI_EXPORT NativeReactNativeAppleHealthKitCxxSpec : public TurboModule {
189
237
  public:
190
238
  jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
191
239
  return delegate_.create(rt, propName);
@@ -195,19 +243,19 @@ public:
195
243
  return delegate_.getPropertyNames(runtime);
196
244
  }
197
245
 
198
- static constexpr std::string_view kModuleName = "AppleHealthKit";
246
+ static constexpr std::string_view kModuleName = "ReactNativeAppleHealthKit";
199
247
 
200
248
  protected:
201
- NativeAppleHealthKitCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
202
- : TurboModule(std::string{NativeAppleHealthKitCxxSpec::kModuleName}, jsInvoker),
249
+ NativeReactNativeAppleHealthKitCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
250
+ : TurboModule(std::string{NativeReactNativeAppleHealthKitCxxSpec::kModuleName}, jsInvoker),
203
251
  delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
204
252
 
205
253
 
206
254
  private:
207
- class Delegate : public NativeAppleHealthKitCxxSpecJSI {
255
+ class Delegate : public NativeReactNativeAppleHealthKitCxxSpecJSI {
208
256
  public:
209
257
  Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
210
- NativeAppleHealthKitCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
258
+ NativeReactNativeAppleHealthKitCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
211
259
 
212
260
  }
213
261
 
@@ -245,7 +293,7 @@ private:
245
293
  }
246
294
 
247
295
  private:
248
- friend class NativeAppleHealthKitCxxSpec;
296
+ friend class NativeReactNativeAppleHealthKitCxxSpec;
249
297
  T *instance_;
250
298
  };
251
299
 
@@ -1,7 +1,14 @@
1
+ //
2
+ // HealthKitManager.swift
3
+ // ReactNativeAppleHealthKit
4
+ //
5
+ // Created by Andrei on 24.02.2025.
6
+ //
7
+
1
8
  import Foundation
2
9
  import HealthKit
3
10
 
4
- @objc public class AppleHealthKitManager: NSObject {
11
+ @objc public class HealthKitManager: NSObject {
5
12
 
6
13
  private let healthStore = HKHealthStore()
7
14
  private let permissions = HealthKitPermissions()
@@ -1,6 +1,13 @@
1
+ //
2
+ // HealthKitPermissions.swift
3
+ // ReactNativeAppleHealthKit
4
+ //
5
+ // Created by Andrei on 24.02.2025.
6
+ //
7
+
1
8
  import HealthKit
2
9
 
3
- class HealthKitPermissions {
10
+ class HealthKitPermissions {
4
11
  let healthStore = HKHealthStore()
5
12
 
6
13
  func requestPermissions(completion: @escaping (Bool, Error?) -> Void) {
@@ -1,3 +1,11 @@
1
+ //
2
+ // HealthKitQueries.swift
3
+ // ReactNativeAppleHealthKit
4
+ //
5
+ // Created by Andrei on 24.02.2025.
6
+ //
7
+
8
+ import Foundation
1
9
  import HealthKit
2
10
 
3
11
  class HealthKitQueries {
@@ -0,0 +1,6 @@
1
+
2
+ #import "generated/RNReactNativeAppleHealthKitSpec/RNReactNativeAppleHealthKitSpec.h"
3
+
4
+ @interface ReactNativeAppleHealthKit : NSObject <NativeReactNativeAppleHealthKitSpec>
5
+
6
+ @end
@@ -1,14 +1,14 @@
1
- #import "AppleHealthKit.h"
2
- #import "AppleHealthKit-Swift.h"
1
+ #import "ReactNativeAppleHealthKit.h"
2
+ #import "ReactNativeAppleHealthKit-Swift.h"
3
3
 
4
- @implementation AppleHealthKit {
5
- AppleHealthKitManager *moduleImpl;
4
+ @implementation ReactNativeAppleHealthKit {
5
+ HealthKitManager *moduleImpl;
6
6
  }
7
7
 
8
8
  - (instancetype)init {
9
9
  self = [super init];
10
10
  if (self) {
11
- moduleImpl = [[AppleHealthKitManager alloc] init];
11
+ moduleImpl = [[HealthKitManager alloc] init];
12
12
  }
13
13
  return self;
14
14
  }
@@ -18,7 +18,7 @@ RCT_EXPORT_MODULE()
18
18
  - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
19
19
  (const facebook::react::ObjCTurboModule::InitParams &)params
20
20
  {
21
- return std::make_shared<facebook::react::NativeAppleHealthKitSpecJSI>(params);
21
+ return std::make_shared<facebook::react::NativeReactNativeAppleHealthKitSpecJSI>(params);
22
22
  }
23
23
 
24
24
  RCT_EXPORT_METHOD(requestHealthKitPermissions:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) {
@@ -41,7 +41,7 @@ RCT_EXPORT_METHOD(getSteps:(double)daysBefore resolve:(RCTPromiseResolveBlock)re
41
41
  }];
42
42
  }
43
43
 
44
- - (void)getHeartRate:(double)daysBefore resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
44
+ - (void)getHeartRate:(double)daysBefore resolve:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
45
45
  [moduleImpl getHeartRateWithDaysBefore:@(daysBefore) completion:^(NSArray * _Nullable steps, NSError * _Nullable error) {
46
46
  if (error) {
47
47
  reject(@"heart_rate_error", error.localizedDescription, error);
@@ -52,7 +52,7 @@ RCT_EXPORT_METHOD(getSteps:(double)daysBefore resolve:(RCTPromiseResolveBlock)re
52
52
  }
53
53
 
54
54
 
55
- - (void)getMeasurement:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
55
+ - (void)getMeasurement:(nonnull RCTPromiseResolveBlock)resolve reject:(nonnull RCTPromiseRejectBlock)reject {
56
56
  [moduleImpl getMeasurementsWithCompletion:^(NSDictionary<NSString *, id> * _Nullable data) {
57
57
  resolve(data);
58
58
  }];
@@ -1,8 +1,8 @@
1
1
  //
2
2
  // Utils.swift
3
- // AppleHealthKit
3
+ // ReactNativeAppleHealthKit
4
4
  //
5
- // Created by Andrei on 23.02.2025.
5
+ // Created by Andrei on 24.02.2025.
6
6
  //
7
7
 
8
8
  import Foundation
@@ -11,10 +11,10 @@
11
11
  * must have a single output. More files => more genrule()s => slower builds.
12
12
  */
13
13
 
14
- #import "RNAppleHealthKitSpec.h"
14
+ #import "RNReactNativeAppleHealthKitSpec.h"
15
15
 
16
16
 
17
- @implementation NativeAppleHealthKitSpecBase
17
+ @implementation NativeReactNativeAppleHealthKitSpecBase
18
18
 
19
19
 
20
20
  - (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
@@ -26,35 +26,35 @@
26
26
 
27
27
  namespace facebook::react {
28
28
 
29
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
29
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_requestHealthKitPermissions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
30
30
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "requestHealthKitPermissions", @selector(requestHealthKitPermissions:reject:), args, count);
31
31
  }
32
32
 
33
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getSteps(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
33
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getSteps(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
34
34
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSteps", @selector(getSteps:resolve:reject:), args, count);
35
35
  }
36
36
 
37
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
37
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getHeartRate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
38
38
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getHeartRate", @selector(getHeartRate:resolve:reject:), args, count);
39
39
  }
40
40
 
41
- static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
41
+ static facebook::jsi::Value __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getMeasurement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
42
42
  return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getMeasurement", @selector(getMeasurement:reject:), args, count);
43
43
  }
44
44
 
45
- NativeAppleHealthKitSpecJSI::NativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams &params)
45
+ NativeReactNativeAppleHealthKitSpecJSI::NativeReactNativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams &params)
46
46
  : ObjCTurboModule(params) {
47
47
 
48
- methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions};
48
+ methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_requestHealthKitPermissions};
49
49
 
50
50
 
51
- methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getSteps};
51
+ methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getSteps};
52
52
 
53
53
 
54
- methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate};
54
+ methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getHeartRate};
55
55
 
56
56
 
57
- methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement};
57
+ methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeReactNativeAppleHealthKitSpecJSI_getMeasurement};
58
58
 
59
59
  }
60
60
  } // namespace facebook::react
@@ -15,9 +15,9 @@
15
15
  #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
16
  #endif
17
17
 
18
- // Avoid multiple includes of RNAppleHealthKitSpec symbols
19
- #ifndef RNAppleHealthKitSpec_H
20
- #define RNAppleHealthKitSpec_H
18
+ // Avoid multiple includes of RNReactNativeAppleHealthKitSpec symbols
19
+ #ifndef RNReactNativeAppleHealthKitSpec_H
20
+ #define RNReactNativeAppleHealthKitSpec_H
21
21
 
22
22
  #import <Foundation/Foundation.h>
23
23
  #import <RCTRequired/RCTRequired.h>
@@ -33,7 +33,7 @@
33
33
 
34
34
  NS_ASSUME_NONNULL_BEGIN
35
35
 
36
- @protocol NativeAppleHealthKitSpec <RCTBridgeModule, RCTTurboModule>
36
+ @protocol NativeReactNativeAppleHealthKitSpec <RCTBridgeModule, RCTTurboModule>
37
37
 
38
38
  - (void)requestHealthKitPermissions:(RCTPromiseResolveBlock)resolve
39
39
  reject:(RCTPromiseRejectBlock)reject;
@@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
48
48
 
49
49
  @end
50
50
 
51
- @interface NativeAppleHealthKitSpecBase : NSObject {
51
+ @interface NativeReactNativeAppleHealthKitSpecBase : NSObject {
52
52
  @protected
53
53
  facebook::react::EventEmitterCallback _eventEmitterCallback;
54
54
  }
@@ -59,13 +59,13 @@ facebook::react::EventEmitterCallback _eventEmitterCallback;
59
59
 
60
60
  namespace facebook::react {
61
61
  /**
62
- * ObjC++ class for module 'NativeAppleHealthKit'
62
+ * ObjC++ class for module 'NativeReactNativeAppleHealthKit'
63
63
  */
64
- class JSI_EXPORT NativeAppleHealthKitSpecJSI : public ObjCTurboModule {
64
+ class JSI_EXPORT NativeReactNativeAppleHealthKitSpecJSI : public ObjCTurboModule {
65
65
  public:
66
- NativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams &params);
66
+ NativeReactNativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams &params);
67
67
  };
68
68
  } // namespace facebook::react
69
69
 
70
70
  NS_ASSUME_NONNULL_END
71
- #endif // RNAppleHealthKitSpec_H
71
+ #endif // RNReactNativeAppleHealthKitSpec_H