@gromozeqa/react-native-apple-health-kit 0.1.3
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/AppleHealthKit.podspec +42 -0
- package/LICENSE +20 -0
- package/README.md +22 -0
- package/android/generated/java/com/applehealthkit/NativeAppleHealthKitSpec.java +50 -0
- package/android/generated/jni/CMakeLists.txt +36 -0
- package/android/generated/jni/RNAppleHealthKitSpec-generated.cpp +50 -0
- package/android/generated/jni/RNAppleHealthKitSpec.h +31 -0
- package/android/generated/jni/react/renderer/components/RNAppleHealthKitSpec/RNAppleHealthKitSpecJSI-generated.cpp +46 -0
- package/android/generated/jni/react/renderer/components/RNAppleHealthKitSpec/RNAppleHealthKitSpecJSI.h +255 -0
- package/ios/AppleHealthKit.h +6 -0
- package/ios/AppleHealthKit.mm +61 -0
- package/ios/AppleHealthKitManager.swift +48 -0
- package/ios/AppleHealthKitPermissions.swift +26 -0
- package/ios/AppleHealthKitQueries.swift +200 -0
- package/ios/HealthKitUtils.swift +61 -0
- package/ios/generated/RNAppleHealthKitSpec/RNAppleHealthKitSpec-generated.mm +60 -0
- package/ios/generated/RNAppleHealthKitSpec/RNAppleHealthKitSpec.h +71 -0
- package/ios/generated/RNAppleHealthKitSpecJSI-generated.cpp +46 -0
- package/ios/generated/RNAppleHealthKitSpecJSI.h +255 -0
- package/lib/commonjs/NativeAppleHealthKit.js +23 -0
- package/lib/commonjs/NativeAppleHealthKit.js.map +1 -0
- package/lib/commonjs/index.js +19 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeAppleHealthKit.js +19 -0
- package/lib/module/NativeAppleHealthKit.js.map +1 -0
- package/lib/module/index.js +10 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeAppleHealthKit.d.ts +27 -0
- package/lib/typescript/commonjs/src/NativeAppleHealthKit.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +2 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeAppleHealthKit.d.ts +27 -0
- package/lib/typescript/module/src/NativeAppleHealthKit.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +2 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +203 -0
- package/react-native.config.js +11 -0
- package/src/NativeAppleHealthKit.ts +48 -0
- package/src/index.tsx +8 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
import HealthKit
|
2
|
+
|
3
|
+
class HealthKitPermissions {
|
4
|
+
let healthStore = HKHealthStore()
|
5
|
+
|
6
|
+
func requestPermissions(completion: @escaping (Bool, Error?) -> Void) {
|
7
|
+
guard HKHealthStore.isHealthDataAvailable() else {
|
8
|
+
let error = NSError(domain: "HealthKit", code: -1, userInfo: [NSLocalizedDescriptionKey: "HealthKit is not available on this device."])
|
9
|
+
completion(false, error)
|
10
|
+
return
|
11
|
+
}
|
12
|
+
|
13
|
+
var allTypes: Set = [
|
14
|
+
HKObjectType.quantityType(forIdentifier: .heartRate)!,
|
15
|
+
HKObjectType.quantityType(forIdentifier: .stepCount)!,
|
16
|
+
HKObjectType.quantityType(forIdentifier: .distanceWalkingRunning)!,
|
17
|
+
HKObjectType.quantityType(forIdentifier: .appleExerciseTime)!,
|
18
|
+
HKQuantityType.quantityType(forIdentifier: .height)!,
|
19
|
+
HKQuantityType.quantityType(forIdentifier: .bodyMass)!,
|
20
|
+
HKSampleType.characteristicType(forIdentifier: .biologicalSex)!,
|
21
|
+
HKSampleType.characteristicType(forIdentifier: .dateOfBirth)!
|
22
|
+
]
|
23
|
+
|
24
|
+
healthStore.requestAuthorization(toShare: [], read: allTypes, completion: completion)
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,200 @@
|
|
1
|
+
import HealthKit
|
2
|
+
|
3
|
+
class HealthKitQueries {
|
4
|
+
private let healthStore = HKHealthStore()
|
5
|
+
|
6
|
+
func getStepsQuery(daysBefore: Int, completion: @escaping ([[String: Any]]?, Error?) -> Void) {
|
7
|
+
let calendar = Calendar(identifier: .gregorian)
|
8
|
+
let endDate = Date()
|
9
|
+
let startDate = calendar.date(byAdding: .day, value: -daysBefore, to: endDate)!
|
10
|
+
let anchorDate = calendar.startOfDay(for: endDate)
|
11
|
+
let interval = DateComponents(day: 1)
|
12
|
+
|
13
|
+
let query = HKStatisticsCollectionQuery(
|
14
|
+
quantityType: HKObjectType.quantityType(forIdentifier: .heartRate)!,
|
15
|
+
quantitySamplePredicate: HKQuery.predicateForSamples(withStart: startDate, end: endDate),
|
16
|
+
anchorDate: anchorDate,
|
17
|
+
intervalComponents: interval
|
18
|
+
)
|
19
|
+
|
20
|
+
query.initialResultsHandler = { _, results, error in
|
21
|
+
if let error = error {
|
22
|
+
completion(nil, error)
|
23
|
+
return
|
24
|
+
}
|
25
|
+
|
26
|
+
var stepsDictionaries: [[String: Any]] = []
|
27
|
+
|
28
|
+
results?.enumerateStatistics(from: startDate, to: endDate) { statistics, _ in
|
29
|
+
if let stepCount = statistics.sumQuantity()?.doubleValue(for: HKUnit.count()) {
|
30
|
+
stepsDictionaries.append([
|
31
|
+
"dateString": getShortStringDate(statistics.startDate),
|
32
|
+
"stepCount": stepCount
|
33
|
+
])
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
do {
|
38
|
+
let validStepsDictionaries = try checkIsEmptyArray(stepsDictionaries, "No Health Data Available")
|
39
|
+
completion(validStepsDictionaries, nil)
|
40
|
+
} catch {
|
41
|
+
completion(nil, error)
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
healthStore.execute(query)
|
46
|
+
}
|
47
|
+
|
48
|
+
func getHeartRateQuery(daysBefore: Int, completion: @escaping ([[String: Any]]?, Error?) -> Void) {
|
49
|
+
let quantityType = HKObjectType.quantityType(forIdentifier: .heartRate)!
|
50
|
+
let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false)
|
51
|
+
let calendar = Calendar(identifier: .gregorian)
|
52
|
+
|
53
|
+
let endDate = Date()
|
54
|
+
let startDate = calendar.date(byAdding: .day, value: -daysBefore, to: endDate)!
|
55
|
+
|
56
|
+
let sampleQuery = HKSampleQuery(
|
57
|
+
sampleType: quantityType,
|
58
|
+
predicate: HKQuery.predicateForSamples(withStart: startDate, end: endDate),
|
59
|
+
limit: HKObjectQueryNoLimit,
|
60
|
+
sortDescriptors: [sortDescriptor]
|
61
|
+
) { _, results, error in
|
62
|
+
guard let samples = results as? [HKQuantitySample] else {
|
63
|
+
completion(nil, error)
|
64
|
+
return
|
65
|
+
}
|
66
|
+
|
67
|
+
var heartRateDict: [String: [[String: Any]]] = [:]
|
68
|
+
|
69
|
+
for sample in samples {
|
70
|
+
let dateKey = getShortStringDate(sample.startDate)
|
71
|
+
let timeKey = getTimeString(sample.startDate)
|
72
|
+
let bpm = sample.quantity.doubleValue(for: HKUnit(from: "count/min"))
|
73
|
+
|
74
|
+
let heartRateEntry: [String: Any] = [
|
75
|
+
"time": timeKey,
|
76
|
+
"heartRate": bpm
|
77
|
+
]
|
78
|
+
|
79
|
+
heartRateDict[dateKey, default: []].append(heartRateEntry)
|
80
|
+
}
|
81
|
+
|
82
|
+
var heartRateDictionaries: [[String: Any]] = []
|
83
|
+
for (date, values) in heartRateDict {
|
84
|
+
heartRateDictionaries.append([
|
85
|
+
"date": date,
|
86
|
+
"value": values
|
87
|
+
])
|
88
|
+
}
|
89
|
+
|
90
|
+
do {
|
91
|
+
let validDictionaries = try checkIsEmptyArray(heartRateDictionaries, "No Health Data Available")
|
92
|
+
completion(validDictionaries, nil)
|
93
|
+
} catch {
|
94
|
+
completion(nil, error)
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
healthStore.execute(sampleQuery)
|
99
|
+
}
|
100
|
+
|
101
|
+
private func getHeight(completion: @escaping (Double?) -> Void) {
|
102
|
+
let heightType = HKQuantityType.quantityType(forIdentifier: .height)!
|
103
|
+
let query = HKSampleQuery(sampleType: heightType, predicate: nil, limit: 1, sortDescriptors: nil) { (query, results, error) in
|
104
|
+
if let result = results?.first as? HKQuantitySample {
|
105
|
+
let heightInMeters = result.quantity.doubleValue(for: HKUnit.meter())
|
106
|
+
completion(heightInMeters)
|
107
|
+
} else {
|
108
|
+
completion(nil)
|
109
|
+
}
|
110
|
+
}
|
111
|
+
healthStore.execute(query)
|
112
|
+
}
|
113
|
+
|
114
|
+
private func getBiologicalSex(completion: @escaping (HKBiologicalSexObject?) -> Void) {
|
115
|
+
do {
|
116
|
+
let biologicalSex = try healthStore.biologicalSex()
|
117
|
+
completion(biologicalSex)
|
118
|
+
} catch {
|
119
|
+
completion(nil)
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
private func getDateOfBirth(completion: @escaping (DateComponents?) -> Void) {
|
124
|
+
do {
|
125
|
+
let dateOfBirth = try healthStore.dateOfBirthComponents()
|
126
|
+
completion(dateOfBirth)
|
127
|
+
} catch {
|
128
|
+
completion(nil)
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
private func getBodyMass(completion: @escaping (Double?) -> Void) {
|
133
|
+
let bodyMassType = HKQuantityType.quantityType(forIdentifier: .bodyMass)!
|
134
|
+
let query = HKSampleQuery(sampleType: bodyMassType, predicate: nil, limit: 1, sortDescriptors: nil) { (query, results, error) in
|
135
|
+
if let result = results?.first as? HKQuantitySample {
|
136
|
+
let bodyMassInKilograms = result.quantity.doubleValue(for: HKUnit.gramUnit(with: .kilo))
|
137
|
+
completion(bodyMassInKilograms)
|
138
|
+
} else {
|
139
|
+
completion(nil)
|
140
|
+
}
|
141
|
+
}
|
142
|
+
healthStore.execute(query)
|
143
|
+
}
|
144
|
+
|
145
|
+
@objc public func getMeasurementsQuery(completion: @escaping ([String: AnyObject]?) -> Void) {
|
146
|
+
var healthData: [String: Any?] = [
|
147
|
+
"bodyMass": nil,
|
148
|
+
"height": nil,
|
149
|
+
"biologicalSex": nil,
|
150
|
+
"dateOfBirth": nil
|
151
|
+
]
|
152
|
+
|
153
|
+
let dispatchGroup = DispatchGroup()
|
154
|
+
|
155
|
+
// Fetch Height
|
156
|
+
dispatchGroup.enter()
|
157
|
+
getHeight { height in
|
158
|
+
healthData["height"] = height
|
159
|
+
dispatchGroup.leave()
|
160
|
+
}
|
161
|
+
|
162
|
+
// Fetch Biological Sex
|
163
|
+
dispatchGroup.enter()
|
164
|
+
getBiologicalSex { biologicalSex in
|
165
|
+
if let biologicalSex = biologicalSex {
|
166
|
+
healthData["biologicalSex"] = biologicalSexToString(biologicalSex.biologicalSex)
|
167
|
+
}
|
168
|
+
dispatchGroup.leave()
|
169
|
+
}
|
170
|
+
|
171
|
+
// Fetch Date of Birth
|
172
|
+
dispatchGroup.enter()
|
173
|
+
getDateOfBirth { dateOfBirth in
|
174
|
+
if let dateOfBirth = dateOfBirth {
|
175
|
+
healthData["dateOfBirth"] = dateComponentsToString(dateOfBirth)
|
176
|
+
}
|
177
|
+
dispatchGroup.leave()
|
178
|
+
}
|
179
|
+
|
180
|
+
// Fetch Body Mass
|
181
|
+
dispatchGroup.enter()
|
182
|
+
getBodyMass { bodyMass in
|
183
|
+
healthData["bodyMass"] = bodyMass
|
184
|
+
dispatchGroup.leave()
|
185
|
+
}
|
186
|
+
|
187
|
+
// Notify when all tasks are done
|
188
|
+
dispatchGroup.notify(queue: .main) {
|
189
|
+
let objectiveCHealthData = healthData.mapValues { value in
|
190
|
+
if let value = value {
|
191
|
+
return value as AnyObject
|
192
|
+
} else {
|
193
|
+
return NSNull()
|
194
|
+
}
|
195
|
+
}
|
196
|
+
completion(objectiveCHealthData)
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
//
|
2
|
+
// Utils.swift
|
3
|
+
// AppleHealthKit
|
4
|
+
//
|
5
|
+
// Created by Andrei on 23.02.2025.
|
6
|
+
//
|
7
|
+
|
8
|
+
import Foundation
|
9
|
+
import HealthKit
|
10
|
+
|
11
|
+
func filterNonZeroDictionaries(_ stepsDictionaries: [[String: Any]]) -> [[String: Any]] {
|
12
|
+
return stepsDictionaries.filter { dictionary in
|
13
|
+
if let stepCount = dictionary["stepCount"] as? Double {
|
14
|
+
return stepCount > 0.0
|
15
|
+
}
|
16
|
+
return false
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
func checkIsEmptyArray(_ array: [[String: Any]], _ errorMessage: NSString) throws -> [[String: Any]] {
|
21
|
+
if array.isEmpty {
|
22
|
+
throw NSError(domain: "com.yourapp.healthkit", code: -1, userInfo: [NSLocalizedDescriptionKey: errorMessage])
|
23
|
+
}
|
24
|
+
return array
|
25
|
+
}
|
26
|
+
|
27
|
+
func getShortStringDate(_ date: Date) -> String {
|
28
|
+
let formatter = DateFormatter()
|
29
|
+
formatter.dateStyle = .short
|
30
|
+
|
31
|
+
return formatter.string(from: date)
|
32
|
+
}
|
33
|
+
|
34
|
+
func dateComponentsToString(_ dateComponents: DateComponents) -> String {
|
35
|
+
let calendar = Calendar.current
|
36
|
+
if let date = calendar.date(from: dateComponents) {
|
37
|
+
let dateFormatter = DateFormatter()
|
38
|
+
dateFormatter.dateFormat = "yyyy-MM-dd"
|
39
|
+
return dateFormatter.string(from: date)
|
40
|
+
}
|
41
|
+
return "Unknown"
|
42
|
+
}
|
43
|
+
|
44
|
+
func biologicalSexToString(_ biologicalSex: HKBiologicalSex) -> String {
|
45
|
+
switch biologicalSex {
|
46
|
+
case .female:
|
47
|
+
return "Female"
|
48
|
+
case .male:
|
49
|
+
return "Male"
|
50
|
+
case .other:
|
51
|
+
return "Other"
|
52
|
+
default:
|
53
|
+
return "Not Set"
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
func getTimeString(_ date: Date) -> String {
|
58
|
+
let formatter = DateFormatter()
|
59
|
+
formatter.dateFormat = "HH:mm"
|
60
|
+
return formatter.string(from: date)
|
61
|
+
}
|
@@ -0,0 +1,60 @@
|
|
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: GenerateModuleObjCpp
|
8
|
+
*
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#import "RNAppleHealthKitSpec.h"
|
15
|
+
|
16
|
+
|
17
|
+
@implementation NativeAppleHealthKitSpecBase
|
18
|
+
|
19
|
+
|
20
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper
|
21
|
+
{
|
22
|
+
_eventEmitterCallback = std::move(eventEmitterCallbackWrapper->_eventEmitterCallback);
|
23
|
+
}
|
24
|
+
@end
|
25
|
+
|
26
|
+
|
27
|
+
namespace facebook::react {
|
28
|
+
|
29
|
+
static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
30
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "requestHealthKitPermissions", @selector(requestHealthKitPermissions:reject:), args, count);
|
31
|
+
}
|
32
|
+
|
33
|
+
static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getSteps(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
34
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getSteps", @selector(getSteps:resolve:reject:), args, count);
|
35
|
+
}
|
36
|
+
|
37
|
+
static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
38
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getHeartRate", @selector(getHeartRate:resolve:reject:), args, count);
|
39
|
+
}
|
40
|
+
|
41
|
+
static facebook::jsi::Value __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
|
42
|
+
return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getMeasurement", @selector(getMeasurement:reject:), args, count);
|
43
|
+
}
|
44
|
+
|
45
|
+
NativeAppleHealthKitSpecJSI::NativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams ¶ms)
|
46
|
+
: ObjCTurboModule(params) {
|
47
|
+
|
48
|
+
methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_requestHealthKitPermissions};
|
49
|
+
|
50
|
+
|
51
|
+
methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getSteps};
|
52
|
+
|
53
|
+
|
54
|
+
methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitSpecJSI_getHeartRate};
|
55
|
+
|
56
|
+
|
57
|
+
methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitSpecJSI_getMeasurement};
|
58
|
+
|
59
|
+
}
|
60
|
+
} // namespace facebook::react
|
@@ -0,0 +1,71 @@
|
|
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: GenerateModuleObjCpp
|
8
|
+
*
|
9
|
+
* We create an umbrella header (and corresponding implementation) here since
|
10
|
+
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
|
11
|
+
* must have a single output. More files => more genrule()s => slower builds.
|
12
|
+
*/
|
13
|
+
|
14
|
+
#ifndef __cplusplus
|
15
|
+
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
|
16
|
+
#endif
|
17
|
+
|
18
|
+
// Avoid multiple includes of RNAppleHealthKitSpec symbols
|
19
|
+
#ifndef RNAppleHealthKitSpec_H
|
20
|
+
#define RNAppleHealthKitSpec_H
|
21
|
+
|
22
|
+
#import <Foundation/Foundation.h>
|
23
|
+
#import <RCTRequired/RCTRequired.h>
|
24
|
+
#import <RCTTypeSafety/RCTConvertHelpers.h>
|
25
|
+
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
|
26
|
+
#import <React/RCTBridgeModule.h>
|
27
|
+
#import <React/RCTCxxConvert.h>
|
28
|
+
#import <React/RCTManagedPointer.h>
|
29
|
+
#import <ReactCommon/RCTTurboModule.h>
|
30
|
+
#import <optional>
|
31
|
+
#import <vector>
|
32
|
+
|
33
|
+
|
34
|
+
NS_ASSUME_NONNULL_BEGIN
|
35
|
+
|
36
|
+
@protocol NativeAppleHealthKitSpec <RCTBridgeModule, RCTTurboModule>
|
37
|
+
|
38
|
+
- (void)requestHealthKitPermissions:(RCTPromiseResolveBlock)resolve
|
39
|
+
reject:(RCTPromiseRejectBlock)reject;
|
40
|
+
- (void)getSteps:(double)daysBefore
|
41
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
42
|
+
reject:(RCTPromiseRejectBlock)reject;
|
43
|
+
- (void)getHeartRate:(double)daysBefore
|
44
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
45
|
+
reject:(RCTPromiseRejectBlock)reject;
|
46
|
+
- (void)getMeasurement:(RCTPromiseResolveBlock)resolve
|
47
|
+
reject:(RCTPromiseRejectBlock)reject;
|
48
|
+
|
49
|
+
@end
|
50
|
+
|
51
|
+
@interface NativeAppleHealthKitSpecBase : NSObject {
|
52
|
+
@protected
|
53
|
+
facebook::react::EventEmitterCallback _eventEmitterCallback;
|
54
|
+
}
|
55
|
+
- (void)setEventEmitterCallback:(EventEmitterCallbackWrapper *)eventEmitterCallbackWrapper;
|
56
|
+
|
57
|
+
|
58
|
+
@end
|
59
|
+
|
60
|
+
namespace facebook::react {
|
61
|
+
/**
|
62
|
+
* ObjC++ class for module 'NativeAppleHealthKit'
|
63
|
+
*/
|
64
|
+
class JSI_EXPORT NativeAppleHealthKitSpecJSI : public ObjCTurboModule {
|
65
|
+
public:
|
66
|
+
NativeAppleHealthKitSpecJSI(const ObjCTurboModule::InitParams ¶ms);
|
67
|
+
};
|
68
|
+
} // namespace facebook::react
|
69
|
+
|
70
|
+
NS_ASSUME_NONNULL_END
|
71
|
+
#endif // RNAppleHealthKitSpec_H
|
@@ -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 "RNAppleHealthKitSpecJSI.h"
|
11
|
+
|
12
|
+
namespace facebook::react {
|
13
|
+
|
14
|
+
static jsi::Value __hostFunction_NativeAppleHealthKitCxxSpecJSI_requestHealthKitPermissions(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
15
|
+
return static_cast<NativeAppleHealthKitCxxSpecJSI *>(&turboModule)->requestHealthKitPermissions(
|
16
|
+
rt
|
17
|
+
);
|
18
|
+
}
|
19
|
+
static jsi::Value __hostFunction_NativeAppleHealthKitCxxSpecJSI_getSteps(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
20
|
+
return static_cast<NativeAppleHealthKitCxxSpecJSI *>(&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_NativeAppleHealthKitCxxSpecJSI_getHeartRate(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
26
|
+
return static_cast<NativeAppleHealthKitCxxSpecJSI *>(&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_NativeAppleHealthKitCxxSpecJSI_getMeasurement(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
|
32
|
+
return static_cast<NativeAppleHealthKitCxxSpecJSI *>(&turboModule)->getMeasurement(
|
33
|
+
rt
|
34
|
+
);
|
35
|
+
}
|
36
|
+
|
37
|
+
NativeAppleHealthKitCxxSpecJSI::NativeAppleHealthKitCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
|
38
|
+
: TurboModule("AppleHealthKit", jsInvoker) {
|
39
|
+
methodMap_["requestHealthKitPermissions"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitCxxSpecJSI_requestHealthKitPermissions};
|
40
|
+
methodMap_["getSteps"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitCxxSpecJSI_getSteps};
|
41
|
+
methodMap_["getHeartRate"] = MethodMetadata {1, __hostFunction_NativeAppleHealthKitCxxSpecJSI_getHeartRate};
|
42
|
+
methodMap_["getMeasurement"] = MethodMetadata {0, __hostFunction_NativeAppleHealthKitCxxSpecJSI_getMeasurement};
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
} // namespace facebook::react
|