@kingstinct/react-native-healthkit 11.1.1 → 12.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Constants.swift +1 -0
- package/ios/CoreModule.swift +22 -11
- package/ios/Helpers.swift +10 -4
- package/ios/QuantityTypeModule.swift +3 -8
- package/ios/WorkoutsModule.swift +9 -11
- package/lib/commonjs/healthkit.js +1 -2
- package/lib/commonjs/hooks/useHealthkitAuthorization.js +14 -8
- package/lib/commonjs/types/Constants.js +7 -2
- package/lib/module/healthkit.js +1 -2
- package/lib/module/hooks/useHealthkitAuthorization.js +14 -8
- package/lib/module/types/Constants.js +6 -1
- package/lib/typescript/healthkit.d.ts +10 -7
- package/lib/typescript/healthkit.ios.d.ts +16 -13
- package/lib/typescript/hooks/useHealthkitAuthorization.d.ts +4 -1
- 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/Constants.d.ts +6 -1
- package/lib/typescript/types/Device.d.ts +8 -8
- package/lib/typescript/types/Shared.d.ts +2 -2
- package/lib/typescript/types/Source.d.ts +2 -2
- package/lib/typescript/types/Workouts.d.ts +1 -1
- 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/ObjectTypeIdentifier.swift +4 -0
- 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/SampleTypeIdentifier.swift +4 -0
- 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++/ObjectTypeIdentifier.hpp +5 -1
- 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++/SampleTypeIdentifier.hpp +4 -0
- 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.ts +2 -4
- package/src/hooks/useHealthkitAuthorization.test.ts +12 -4
- package/src/hooks/useHealthkitAuthorization.ts +20 -14
- 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/Constants.ts +8 -1
- package/src/types/Device.ts +8 -8
- package/src/types/InterfaceVerificationExample.ts +2 -2
- package/src/types/Shared.ts +2 -0
- package/src/types/Source.ts +2 -2
- package/src/types/Workouts.ts +1 -1
package/ios/Constants.swift
CHANGED
|
@@ -24,6 +24,7 @@ let HKWorkoutTypeIdentifier = "HKWorkoutTypeIdentifier"
|
|
|
24
24
|
let HKWorkoutRouteTypeIdentifier = "HKWorkoutRouteTypeIdentifier"
|
|
25
25
|
let HKDataTypeIdentifierHeartbeatSeries = "HKDataTypeIdentifierHeartbeatSeries"
|
|
26
26
|
let HKStateOfMindTypeIdentifier = "HKStateOfMindTypeIdentifier"
|
|
27
|
+
let HKElectrocardiogramType = "HKElectrocardiogramType"
|
|
27
28
|
|
|
28
29
|
let HKWorkoutActivityTypePropertyName = "activityType"
|
|
29
30
|
let HKWorkoutSessionLocationTypePropertyName = "locationType"
|
package/ios/CoreModule.swift
CHANGED
|
@@ -9,7 +9,12 @@ import NitroModules
|
|
|
9
9
|
|
|
10
10
|
var store = HKHealthStore.init()
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
// Thread-safe cache with concurrent read/exclusive write access
|
|
13
|
+
private let quantityTypeCacheQueue = DispatchQueue(
|
|
14
|
+
label: "com.kingstinct.healthkit.cache",
|
|
15
|
+
attributes: .concurrent
|
|
16
|
+
)
|
|
17
|
+
private var quantityTypeUnitCache = [HKQuantityType: HKUnit]()
|
|
13
18
|
|
|
14
19
|
func getUnitToUse(unitOverride: String?, quantityType: HKQuantityType) async throws -> HKUnit {
|
|
15
20
|
if let unitOverride = unitOverride {
|
|
@@ -32,8 +37,11 @@ func getUnitToUse(unitOverride: String?, quantityType: HKQuantityType) async thr
|
|
|
32
37
|
func getPreferredUnitsInternal(quantityTypes: [HKQuantityType], forceUpdate: Bool? = false) async throws -> [HKQuantityType: HKUnit] {
|
|
33
38
|
|
|
34
39
|
if forceUpdate != true {
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
// Thread-safe read: concurrent reads are allowed
|
|
41
|
+
let itemsInCache = quantityTypeCacheQueue.sync {
|
|
42
|
+
return quantityTypeUnitCache.filter {
|
|
43
|
+
quantityTypes.contains($0.key)
|
|
44
|
+
}
|
|
37
45
|
}
|
|
38
46
|
if itemsInCache.count == quantityTypes.count {
|
|
39
47
|
return itemsInCache
|
|
@@ -47,8 +55,11 @@ func getPreferredUnitsInternal(quantityTypes: [HKQuantityType], forceUpdate: Boo
|
|
|
47
55
|
return continuation.resume(throwing: error)
|
|
48
56
|
}
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
// Thread-safe write: barrier ensures exclusive access
|
|
59
|
+
quantityTypeCacheQueue.sync(flags: .barrier) {
|
|
60
|
+
typePerUnits.forEach { (type: HKQuantityType, unit: HKUnit) in
|
|
61
|
+
quantityTypeUnitCache.updateValue(unit, forKey: type)
|
|
62
|
+
}
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
return continuation.resume(returning: typePerUnits)
|
|
@@ -98,9 +109,9 @@ class CoreModule: HybridCoreModuleSpec {
|
|
|
98
109
|
throw RuntimeError.error(withMessage: "[react-native-healthkit] got unrecognized AuthorizationStatus with value \(authStatus.rawValue)")
|
|
99
110
|
}
|
|
100
111
|
|
|
101
|
-
func getRequestStatusForAuthorization(
|
|
102
|
-
let toShare = sampleTypesFromArray(typeIdentifiersWriteable: toShare)
|
|
103
|
-
let toRead = objectTypesFromArray(typeIdentifiers: toRead)
|
|
112
|
+
func getRequestStatusForAuthorization(toCheck: AuthDataTypes) throws -> Promise<AuthorizationRequestStatus> {
|
|
113
|
+
let toShare = sampleTypesFromArray(typeIdentifiersWriteable: toCheck.toShare ?? [])
|
|
114
|
+
let toRead = objectTypesFromArray(typeIdentifiers: toCheck.toRead ?? [])
|
|
104
115
|
|
|
105
116
|
return Promise.async {
|
|
106
117
|
try await withCheckedThrowingContinuation { continuation in
|
|
@@ -120,9 +131,9 @@ class CoreModule: HybridCoreModuleSpec {
|
|
|
120
131
|
}
|
|
121
132
|
}
|
|
122
133
|
|
|
123
|
-
func requestAuthorization(
|
|
124
|
-
let share = sampleTypesFromArray(typeIdentifiersWriteable: toShare)
|
|
125
|
-
let toRead = objectTypesFromArray(typeIdentifiers: toRead)
|
|
134
|
+
func requestAuthorization(toRequest: AuthDataTypes) throws -> Promise<Bool> {
|
|
135
|
+
let share = sampleTypesFromArray(typeIdentifiersWriteable: toRequest.toShare ?? [])
|
|
136
|
+
let toRead = objectTypesFromArray(typeIdentifiers: toRequest.toRead ?? [])
|
|
126
137
|
|
|
127
138
|
return Promise.async {
|
|
128
139
|
try await withCheckedThrowingContinuation { continuation in
|
package/ios/Helpers.swift
CHANGED
|
@@ -144,12 +144,12 @@ func createMetadataPredicate(metadataKey: PredicateWithMetadataKey) throws -> NS
|
|
|
144
144
|
let actualValue: Any
|
|
145
145
|
|
|
146
146
|
switch valueVariant {
|
|
147
|
-
case .first(let
|
|
147
|
+
case .first(let boolValue):
|
|
148
|
+
actualValue = NSNumber(value: boolValue ? 1 : 0)
|
|
149
|
+
case .second(let stringValue):
|
|
148
150
|
actualValue = stringValue
|
|
149
|
-
case .
|
|
151
|
+
case .third(let doubleValue):
|
|
150
152
|
actualValue = NSNumber(value: doubleValue)
|
|
151
|
-
case .third(let boolValue):
|
|
152
|
-
actualValue = NSNumber(value: boolValue ? 1 : 0)
|
|
153
153
|
case .fourth(let dateValue):
|
|
154
154
|
actualValue = dateValue
|
|
155
155
|
}
|
|
@@ -413,6 +413,12 @@ private func sampleTypeFromStringNullable(typeIdentifier: String) throws -> HKSa
|
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
|
|
416
|
+
if #available(iOS 14, *) {
|
|
417
|
+
if typeIdentifier == HKElectrocardiogramType {
|
|
418
|
+
return HKSampleType.electrocardiogramType()
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
416
422
|
#if compiler(>=6)
|
|
417
423
|
if #available(iOS 18, *) {
|
|
418
424
|
if typeIdentifier == HKStateOfMindTypeIdentifier {
|
|
@@ -290,17 +290,11 @@ class QuantityTypeModule: HybridQuantityTypeModuleSpec {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
func queryStatisticsCollectionForQuantity(identifier: QuantityTypeIdentifier, statistics: [StatisticsOptions], anchorDate:
|
|
293
|
+
func queryStatisticsCollectionForQuantity(identifier: QuantityTypeIdentifier, statistics: [StatisticsOptions], anchorDate: Date, intervalComponents: IntervalComponents, options: StatisticsQueryOptions?) throws -> Promise<[QueryStatisticsResponse]> {
|
|
294
294
|
let quantityType = try initializeQuantityType(identifier.stringValue)
|
|
295
295
|
|
|
296
296
|
let predicate = try createPredicate(filter: options?.filter)
|
|
297
297
|
|
|
298
|
-
// Convert the anchor date string to Date
|
|
299
|
-
let dateFormatter = ISO8601DateFormatter()
|
|
300
|
-
guard let anchor = dateFormatter.date(from: anchorDate) else {
|
|
301
|
-
throw RuntimeError.error(withMessage: "Invalid anchor date format: " + anchorDate)
|
|
302
|
-
}
|
|
303
|
-
|
|
304
298
|
// Create date components from interval
|
|
305
299
|
var dateComponents = DateComponents()
|
|
306
300
|
if let minute = intervalComponents.minute {
|
|
@@ -324,12 +318,13 @@ class QuantityTypeModule: HybridQuantityTypeModuleSpec {
|
|
|
324
318
|
|
|
325
319
|
return Promise.async {
|
|
326
320
|
let unit = try await getUnitToUse(unitOverride: options?.unit, quantityType: quantityType)
|
|
321
|
+
|
|
327
322
|
return try await withCheckedThrowingContinuation { continuation in
|
|
328
323
|
let query = HKStatisticsCollectionQuery.init(
|
|
329
324
|
quantityType: quantityType,
|
|
330
325
|
quantitySamplePredicate: predicate,
|
|
331
326
|
options: opts,
|
|
332
|
-
anchorDate:
|
|
327
|
+
anchorDate: anchorDate,
|
|
333
328
|
intervalComponents: dateComponents
|
|
334
329
|
)
|
|
335
330
|
|
package/ios/WorkoutsModule.swift
CHANGED
|
@@ -94,20 +94,18 @@ class WorkoutsModule: HybridWorkoutsModuleSpec {
|
|
|
94
94
|
quantities: [QuantitySampleForSaving],
|
|
95
95
|
startDate: Date,
|
|
96
96
|
endDate: Date,
|
|
97
|
-
totals: WorkoutTotals
|
|
98
|
-
metadata: AnyMap
|
|
97
|
+
totals: WorkoutTotals?,
|
|
98
|
+
metadata: AnyMap?
|
|
99
99
|
) throws -> Promise<HybridWorkoutProxySpec> {
|
|
100
100
|
|
|
101
101
|
let type = try initializeWorkoutActivityType(UInt(workoutActivityType.rawValue))
|
|
102
102
|
|
|
103
|
-
//
|
|
104
|
-
if
|
|
105
|
-
|
|
106
|
-
throw RuntimeError.error(withMessage: "endDate must not be less than startDate")
|
|
107
|
-
}
|
|
103
|
+
// ensure that start date is before end date
|
|
104
|
+
if startDate > endDate {
|
|
105
|
+
throw RuntimeError.error(withMessage: "endDate must not be less than startDate")
|
|
108
106
|
}
|
|
109
107
|
|
|
110
|
-
let metadataDeserialized = anyMapToDictionary(metadata)
|
|
108
|
+
let metadataDeserialized = metadata != nil ? anyMapToDictionary(metadata!) : nil
|
|
111
109
|
|
|
112
110
|
var totalEnergyBurned: HKQuantity?
|
|
113
111
|
var totalDistance: HKQuantity?
|
|
@@ -149,8 +147,8 @@ class WorkoutsModule: HybridWorkoutsModuleSpec {
|
|
|
149
147
|
}
|
|
150
148
|
|
|
151
149
|
// if totals are provided override samples
|
|
152
|
-
let rawTotalDistance = totals
|
|
153
|
-
let rawTotalEnergy = totals
|
|
150
|
+
let rawTotalDistance = totals?.distance ?? 0.0
|
|
151
|
+
let rawTotalEnergy = totals?.energyBurned ?? 0.0
|
|
154
152
|
|
|
155
153
|
if rawTotalDistance != 0.0 {
|
|
156
154
|
totalDistance = HKQuantity(unit: .meter(), doubleValue: rawTotalDistance)
|
|
@@ -176,7 +174,7 @@ class WorkoutsModule: HybridWorkoutsModuleSpec {
|
|
|
176
174
|
)
|
|
177
175
|
} else {
|
|
178
176
|
if #available(iOS 11, *) {
|
|
179
|
-
if totalFlightsClimbed
|
|
177
|
+
if let totalFlightsClimbed = totalFlightsClimbed {
|
|
180
178
|
workout = HKWorkout.init(
|
|
181
179
|
activityType: type,
|
|
182
180
|
start: startDate,
|
|
@@ -26,9 +26,8 @@ const Characteristics_1 = require("./types/Characteristics");
|
|
|
26
26
|
__exportStar(require("./types"), exports);
|
|
27
27
|
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${react_native_1.Platform.OS}" not supported. HealthKit is only available on iOS.`;
|
|
28
28
|
let hasWarned = false;
|
|
29
|
-
// @ts-ignore
|
|
30
29
|
function UnavailableFnFromModule(_fn, defaultValue) {
|
|
31
|
-
// @ts-
|
|
30
|
+
// @ts-expect-error
|
|
32
31
|
return () => {
|
|
33
32
|
if (react_native_1.Platform.OS !== 'ios' && !hasWarned) {
|
|
34
33
|
console.warn(notAvailableError);
|
|
@@ -8,21 +8,27 @@ const modules_1 = require("../modules");
|
|
|
8
8
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
9
9
|
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
10
10
|
*/
|
|
11
|
-
const useHealthkitAuthorization = (
|
|
11
|
+
const useHealthkitAuthorization = ({ toWrite, toRead, }) => {
|
|
12
12
|
const [status, setStatus] = (0, react_1.useState)(null);
|
|
13
|
-
const readMemo = (0, react_1.useRef)(
|
|
14
|
-
const writeMemo = (0, react_1.useRef)(
|
|
13
|
+
const readMemo = (0, react_1.useRef)(toRead);
|
|
14
|
+
const writeMemo = (0, react_1.useRef)(toWrite);
|
|
15
15
|
(0, react_1.useEffect)(() => {
|
|
16
|
-
readMemo.current =
|
|
17
|
-
writeMemo.current =
|
|
18
|
-
}, [
|
|
16
|
+
readMemo.current = toRead;
|
|
17
|
+
writeMemo.current = toWrite;
|
|
18
|
+
}, [toRead, toWrite]);
|
|
19
19
|
const refreshAuthStatus = (0, react_1.useCallback)(async () => {
|
|
20
|
-
const auth = await modules_1.Core.getRequestStatusForAuthorization(
|
|
20
|
+
const auth = await modules_1.Core.getRequestStatusForAuthorization({
|
|
21
|
+
toShare: writeMemo.current,
|
|
22
|
+
toRead: readMemo.current,
|
|
23
|
+
});
|
|
21
24
|
setStatus(auth);
|
|
22
25
|
return auth;
|
|
23
26
|
}, []);
|
|
24
27
|
const request = (0, react_1.useCallback)(async () => {
|
|
25
|
-
await modules_1.Core.requestAuthorization(
|
|
28
|
+
await modules_1.Core.requestAuthorization({
|
|
29
|
+
toShare: writeMemo.current,
|
|
30
|
+
toRead: readMemo.current,
|
|
31
|
+
});
|
|
26
32
|
return refreshAuthStatus();
|
|
27
33
|
}, [refreshAuthStatus]);
|
|
28
34
|
(0, react_1.useEffect)(() => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HeartbeatSeriesTypeIdentifier = exports.StateOfMindTypeIdentifier = exports.WorkoutRouteTypeIdentifier = exports.WorkoutTypeIdentifier = void 0;
|
|
3
|
+
exports.ElectrocardiogramTypeIdentifier = exports.HeartbeatSeriesTypeIdentifier = exports.StateOfMindTypeIdentifier = exports.WorkoutRouteTypeIdentifier = exports.WorkoutTypeIdentifier = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Represents a workout type identifier.
|
|
6
6
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkouttypeidentifier Apple Docs HKWorkoutTypeIdentifier}
|
|
@@ -17,7 +17,12 @@ exports.WorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier';
|
|
|
17
17
|
*/
|
|
18
18
|
exports.StateOfMindTypeIdentifier = 'HKStateOfMindTypeIdentifier';
|
|
19
19
|
/**
|
|
20
|
-
* Represents a series sample containing heartbeat data
|
|
20
|
+
* Represents a series sample containing heartbeat data.
|
|
21
21
|
* @see {@link https://developer.apple.com/documentation/healthkit/HKDataTypeIdentifierHeartbeatSeries Apple Docs DataTypeIdentifierHeartbeatSeries}
|
|
22
22
|
*/
|
|
23
23
|
exports.HeartbeatSeriesTypeIdentifier = 'HKDataTypeIdentifierHeartbeatSeries';
|
|
24
|
+
/**
|
|
25
|
+
* A type that identifies samples containing electrocardiogram data.
|
|
26
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkelectrocardiogramtype Apple Docs HKElectrocardiogramType}
|
|
27
|
+
*/
|
|
28
|
+
exports.ElectrocardiogramTypeIdentifier = 'HKElectrocardiogramType';
|
package/lib/module/healthkit.js
CHANGED
|
@@ -4,9 +4,8 @@ import { BiologicalSex, BloodType, FitzpatrickSkinType, WheelchairUse, } from '.
|
|
|
4
4
|
export * from './types';
|
|
5
5
|
const notAvailableError = `[@kingstinct/react-native-healthkit] Platform "${Platform.OS}" not supported. HealthKit is only available on iOS.`;
|
|
6
6
|
let hasWarned = false;
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
function UnavailableFnFromModule(_fn, defaultValue) {
|
|
9
|
-
// @ts-
|
|
8
|
+
// @ts-expect-error
|
|
10
9
|
return () => {
|
|
11
10
|
if (Platform.OS !== 'ios' && !hasWarned) {
|
|
12
11
|
console.warn(notAvailableError);
|
|
@@ -5,21 +5,27 @@ import { Core } from '../modules';
|
|
|
5
5
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
6
6
|
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
7
7
|
*/
|
|
8
|
-
export const useHealthkitAuthorization = (
|
|
8
|
+
export const useHealthkitAuthorization = ({ toWrite, toRead, }) => {
|
|
9
9
|
const [status, setStatus] = useState(null);
|
|
10
|
-
const readMemo = useRef(
|
|
11
|
-
const writeMemo = useRef(
|
|
10
|
+
const readMemo = useRef(toRead);
|
|
11
|
+
const writeMemo = useRef(toWrite);
|
|
12
12
|
useEffect(() => {
|
|
13
|
-
readMemo.current =
|
|
14
|
-
writeMemo.current =
|
|
15
|
-
}, [
|
|
13
|
+
readMemo.current = toRead;
|
|
14
|
+
writeMemo.current = toWrite;
|
|
15
|
+
}, [toRead, toWrite]);
|
|
16
16
|
const refreshAuthStatus = useCallback(async () => {
|
|
17
|
-
const auth = await Core.getRequestStatusForAuthorization(
|
|
17
|
+
const auth = await Core.getRequestStatusForAuthorization({
|
|
18
|
+
toShare: writeMemo.current,
|
|
19
|
+
toRead: readMemo.current,
|
|
20
|
+
});
|
|
18
21
|
setStatus(auth);
|
|
19
22
|
return auth;
|
|
20
23
|
}, []);
|
|
21
24
|
const request = useCallback(async () => {
|
|
22
|
-
await Core.requestAuthorization(
|
|
25
|
+
await Core.requestAuthorization({
|
|
26
|
+
toShare: writeMemo.current,
|
|
27
|
+
toRead: readMemo.current,
|
|
28
|
+
});
|
|
23
29
|
return refreshAuthStatus();
|
|
24
30
|
}, [refreshAuthStatus]);
|
|
25
31
|
useEffect(() => {
|
|
@@ -14,7 +14,12 @@ export const WorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier';
|
|
|
14
14
|
*/
|
|
15
15
|
export const StateOfMindTypeIdentifier = 'HKStateOfMindTypeIdentifier';
|
|
16
16
|
/**
|
|
17
|
-
* Represents a series sample containing heartbeat data
|
|
17
|
+
* Represents a series sample containing heartbeat data.
|
|
18
18
|
* @see {@link https://developer.apple.com/documentation/healthkit/HKDataTypeIdentifierHeartbeatSeries Apple Docs DataTypeIdentifierHeartbeatSeries}
|
|
19
19
|
*/
|
|
20
20
|
export const HeartbeatSeriesTypeIdentifier = 'HKDataTypeIdentifierHeartbeatSeries';
|
|
21
|
+
/**
|
|
22
|
+
* A type that identifies samples containing electrocardiogram data.
|
|
23
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkelectrocardiogramtype Apple Docs HKElectrocardiogramType}
|
|
24
|
+
*/
|
|
25
|
+
export const ElectrocardiogramTypeIdentifier = 'HKElectrocardiogramType';
|
|
@@ -12,11 +12,11 @@ export declare const disableAllBackgroundDelivery: () => Promise<boolean>;
|
|
|
12
12
|
export declare const disableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier) => Promise<boolean>;
|
|
13
13
|
export declare const enableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier, updateFrequency: import("./types").UpdateFrequency) => Promise<boolean>;
|
|
14
14
|
export declare const getPreferredUnits: (identifiers: readonly import("./types").QuantityTypeIdentifier[], forceUpdate?: boolean) => Promise<import("./types").IdentifierWithUnit[]>;
|
|
15
|
-
export declare const getRequestStatusForAuthorization: (
|
|
15
|
+
export declare const getRequestStatusForAuthorization: (toCheck: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<AuthorizationRequestStatus>;
|
|
16
16
|
export declare const isHealthDataAvailable: () => boolean;
|
|
17
17
|
export declare const isHealthDataAvailableAsync: () => Promise<boolean>;
|
|
18
18
|
export declare const querySources: (identifier: import("./types").SampleTypeIdentifier) => Promise<readonly import("./specs/SourceProxy.nitro").SourceProxy[]>;
|
|
19
|
-
export declare const requestAuthorization: (
|
|
19
|
+
export declare const requestAuthorization: (toRequest: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<boolean>;
|
|
20
20
|
export declare const deleteObjects: (objectTypeIdentifier: import("./types").ObjectTypeIdentifier, filter: import("./types").FilterForSamples) => Promise<number>;
|
|
21
21
|
export declare const subscribeToChanges: (typeIdentifier: import("./types").SampleTypeIdentifier, callback: (args: import("./types").OnChangeCallbackArgs) => void) => string;
|
|
22
22
|
export declare const isProtectedDataAvailable: () => boolean;
|
|
@@ -26,13 +26,13 @@ export declare const areObjectTypesAvailable: (objectTypeIdentifiers: readonly i
|
|
|
26
26
|
export declare const areObjectTypesAvailableAsync: (objectTypeIdentifiers: import("./types").ObjectTypeIdentifier[]) => Promise<Record<string, boolean>>;
|
|
27
27
|
export declare const getBiologicalSex: () => BiologicalSex;
|
|
28
28
|
export declare const getBloodType: () => BloodType;
|
|
29
|
-
export declare const getDateOfBirth: () => Date |
|
|
29
|
+
export declare const getDateOfBirth: () => Date | undefined;
|
|
30
30
|
export declare const getFitzpatrickSkinType: () => FitzpatrickSkinType;
|
|
31
31
|
export declare const getWheelchairUse: () => WheelchairUse;
|
|
32
32
|
export declare const queryQuantitySamples: (identifier: import("./types").QuantityTypeIdentifier, options?: import("./types").QueryOptionsWithSortOrderAndUnit) => Promise<readonly QuantitySample[]>;
|
|
33
33
|
export declare const queryQuantitySamplesWithAnchor: (identifier: import("./types").QuantityTypeIdentifier, options: import("./types").QueryOptionsWithAnchorAndUnit) => Promise<import("./types").QuantitySamplesWithAnchorResponse>;
|
|
34
34
|
export declare const queryStatisticsForQuantity: (identifier: import("./types").QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], options?: import("./types").StatisticsQueryOptions) => Promise<import("./types").QueryStatisticsResponse>;
|
|
35
|
-
export declare const queryStatisticsCollectionForQuantity: (identifier: import("./types").QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate:
|
|
35
|
+
export declare const queryStatisticsCollectionForQuantity: (identifier: import("./types").QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate: Date, intervalComponents: import("./types").IntervalComponents, options?: import("./types").StatisticsQueryOptions) => Promise<readonly import("./types").QueryStatisticsResponse[]>;
|
|
36
36
|
export declare const saveQuantitySample: (identifier: import("./types").QuantityTypeIdentifier, unit: string, value: number, start: Date, end: Date, metadata: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
37
37
|
export declare const isQuantityCompatibleWithUnit: (identifier: import("./types").QuantityTypeIdentifier, unit: string) => boolean;
|
|
38
38
|
export declare function queryCategorySamples<T extends CategoryTypeIdentifier>(_categoryTypeIdentifier: T, _options?: QueryOptionsWithSortOrder): Promise<CategorySampleTyped<T>[]>;
|
|
@@ -46,7 +46,7 @@ export declare const queryElectrocardiogramSamples: (options?: import("./types/E
|
|
|
46
46
|
export declare const queryElectrocardiogramSamplesWithAnchor: (options: import("./types/ElectrocardiogramSample").ECGQueryOptionsWithAnchor) => Promise<import("./types/ElectrocardiogramSample").ElectrocardiogramSamplesWithAnchorResponse>;
|
|
47
47
|
export declare const queryWorkoutSamples: (options: import("./types").WorkoutQueryOptions) => Promise<WorkoutProxy[]>;
|
|
48
48
|
export declare const queryWorkoutSamplesWithAnchor: (options: import("./types").WorkoutQueryOptionsWithAnchor) => Promise<import("./types").QueryWorkoutSamplesWithAnchorResponse>;
|
|
49
|
-
export declare const saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals
|
|
49
|
+
export declare const saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals?: import("./types").WorkoutTotals, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<WorkoutProxy>;
|
|
50
50
|
export declare const startWatchApp: (workoutConfiguration: import("./types").WorkoutConfiguration) => Promise<boolean>;
|
|
51
51
|
export declare const queryStateOfMindSamples: (options?: QueryOptionsWithSortOrder) => Promise<readonly import("./types").StateOfMindSample[]>;
|
|
52
52
|
export declare const saveStateOfMindSample: (date: Date, kind: import("./types").StateOfMindKind, valence: number, labels: readonly import("./types").StateOfMindLabel[], associations: readonly import("./types").StateOfMindAssociation[], metadata?: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
@@ -58,13 +58,16 @@ export declare function useMostRecentCategorySample<T extends CategoryTypeIdenti
|
|
|
58
58
|
export declare const useMostRecentQuantitySample: typeof import("./healthkit.ios").useMostRecentQuantitySample;
|
|
59
59
|
export declare const useMostRecentWorkout: typeof import("./healthkit.ios").useMostRecentWorkout;
|
|
60
60
|
export declare const useSubscribeToChanges: typeof import("./healthkit.ios").useSubscribeToChanges;
|
|
61
|
-
export declare const useHealthkitAuthorization: (
|
|
61
|
+
export declare const useHealthkitAuthorization: ({ toWrite, toRead, }: {
|
|
62
|
+
toRead?: readonly import("./types").ObjectTypeIdentifier[];
|
|
63
|
+
toWrite?: readonly import("./types").SampleTypeIdentifierWriteable[];
|
|
64
|
+
}) => readonly [AuthorizationRequestStatus | null, () => Promise<AuthorizationRequestStatus>];
|
|
62
65
|
export declare const useIsHealthDataAvailable: () => boolean | null;
|
|
63
66
|
export declare const useSources: typeof import("./healthkit.ios").useSources;
|
|
64
67
|
export declare const useStatisticsForQuantity: typeof import("./healthkit.ios").useStatisticsForQuantity;
|
|
65
68
|
export declare const getBiologicalSexAsync: () => Promise<BiologicalSex>;
|
|
66
69
|
export declare const getBloodTypeAsync: () => Promise<BloodType>;
|
|
67
|
-
export declare const getDateOfBirthAsync: () => Promise<Date |
|
|
70
|
+
export declare const getDateOfBirthAsync: () => Promise<Date | undefined>;
|
|
68
71
|
export declare const getFitzpatrickSkinTypeAsync: () => Promise<FitzpatrickSkinType>;
|
|
69
72
|
export declare const getWheelchairUseAsync: () => Promise<WheelchairUse>;
|
|
70
73
|
export declare const unsubscribeQueries: (queryIds: string[]) => number;
|
|
@@ -38,10 +38,10 @@ export declare const disableBackgroundDelivery: (typeIdentifier: import("./types
|
|
|
38
38
|
export declare const enableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier, updateFrequency: import("./types").UpdateFrequency) => Promise<boolean>;
|
|
39
39
|
export declare const getBiologicalSex: () => import("./types").BiologicalSex;
|
|
40
40
|
export declare const getBloodType: () => import("./types").BloodType;
|
|
41
|
-
export declare const getDateOfBirth: () => Date |
|
|
41
|
+
export declare const getDateOfBirth: () => Date | undefined;
|
|
42
42
|
export declare const getFitzpatrickSkinType: () => import("./types").FitzpatrickSkinType;
|
|
43
43
|
export declare const getPreferredUnits: (identifiers: readonly QuantityTypeIdentifier[], forceUpdate?: boolean) => Promise<import("./types").IdentifierWithUnit[]>;
|
|
44
|
-
export declare const getRequestStatusForAuthorization: (
|
|
44
|
+
export declare const getRequestStatusForAuthorization: (toCheck: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<import("./types").AuthorizationRequestStatus>;
|
|
45
45
|
export declare const getWheelchairUse: () => import("./types").WheelchairUse;
|
|
46
46
|
export declare const isHealthDataAvailable: () => boolean;
|
|
47
47
|
export declare const isHealthDataAvailableAsync: () => Promise<boolean>;
|
|
@@ -55,16 +55,16 @@ export declare const queryElectrocardiogramSamplesWithAnchor: (options: import("
|
|
|
55
55
|
export declare const queryQuantitySamples: (identifier: QuantityTypeIdentifier, options?: import("./types").QueryOptionsWithSortOrderAndUnit) => Promise<readonly import("./types").QuantitySample[]>;
|
|
56
56
|
export declare const queryQuantitySamplesWithAnchor: (identifier: QuantityTypeIdentifier, options: import("./types").QueryOptionsWithAnchorAndUnit) => Promise<import("./types").QuantitySamplesWithAnchorResponse>;
|
|
57
57
|
export declare const queryStatisticsForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], options?: import("./types").StatisticsQueryOptions) => Promise<import("./types").QueryStatisticsResponse>;
|
|
58
|
-
export declare const queryStatisticsCollectionForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate:
|
|
58
|
+
export declare const queryStatisticsCollectionForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate: Date, intervalComponents: import("./types").IntervalComponents, options?: import("./types").StatisticsQueryOptions) => Promise<readonly import("./types").QueryStatisticsResponse[]>;
|
|
59
59
|
export declare const queryWorkoutSamples: (options: import("./types").WorkoutQueryOptions) => Promise<import("./specs/WorkoutProxy.nitro").WorkoutProxy[]>;
|
|
60
60
|
export declare const queryWorkoutSamplesWithAnchor: (options: import("./types").WorkoutQueryOptionsWithAnchor) => Promise<import("./types").QueryWorkoutSamplesWithAnchorResponse>;
|
|
61
61
|
export declare const querySources: (identifier: import("./types").SampleTypeIdentifier) => Promise<readonly import("./specs/SourceProxy.nitro").SourceProxy[]>;
|
|
62
|
-
export declare const requestAuthorization: (
|
|
62
|
+
export declare const requestAuthorization: (toRequest: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<boolean>;
|
|
63
63
|
export declare const deleteObjects: (objectTypeIdentifier: import("./types").ObjectTypeIdentifier, filter: import("./types").FilterForSamples) => Promise<number>;
|
|
64
64
|
export declare const saveCategorySample: <T extends import("./types").CategoryTypeIdentifier>(identifier: T, value: import("./types").CategoryValueForIdentifier, startDate: Date, endDate: Date, metadata: import("./types").MetadataForCategoryIdentifier<T>) => Promise<boolean>;
|
|
65
65
|
export declare const saveCorrelationSample: (typeIdentifier: import("./types").CorrelationTypeIdentifier, samples: import("./types").SampleForSaving[], start: Date, end: Date, metadata: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
66
66
|
export declare const saveQuantitySample: (identifier: QuantityTypeIdentifier, unit: string, value: number, start: Date, end: Date, metadata: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
67
|
-
export declare const saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals
|
|
67
|
+
export declare const saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals?: import("./types").WorkoutTotals, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./specs/WorkoutProxy.nitro").WorkoutProxy>;
|
|
68
68
|
export declare const subscribeToChanges: (typeIdentifier: import("./types").SampleTypeIdentifier, callback: (args: import("./types").OnChangeCallbackArgs) => void) => string;
|
|
69
69
|
export declare const startWatchApp: (workoutConfiguration: import("./types").WorkoutConfiguration) => Promise<boolean>;
|
|
70
70
|
export declare const isProtectedDataAvailable: () => boolean;
|
|
@@ -78,7 +78,7 @@ export declare const areObjectTypesAvailable: (objectTypeIdentifiers: readonly i
|
|
|
78
78
|
export declare const areObjectTypesAvailableAsync: (objectTypeIdentifiers: import("./types").ObjectTypeIdentifier[]) => Promise<Record<string, boolean>>;
|
|
79
79
|
export declare const getBiologicalSexAsync: () => Promise<import("./types").BiologicalSex>;
|
|
80
80
|
export declare const getBloodTypeAsync: () => Promise<import("./types").BloodType>;
|
|
81
|
-
export declare const getDateOfBirthAsync: () => Promise<Date |
|
|
81
|
+
export declare const getDateOfBirthAsync: () => Promise<Date | undefined>;
|
|
82
82
|
export declare const getFitzpatrickSkinTypeAsync: () => Promise<import("./types").FitzpatrickSkinType>;
|
|
83
83
|
export declare const getWheelchairUseAsync: () => Promise<import("./types").WheelchairUse>;
|
|
84
84
|
declare const _default: {
|
|
@@ -93,11 +93,11 @@ declare const _default: {
|
|
|
93
93
|
enableBackgroundDelivery: (typeIdentifier: import("./types").ObjectTypeIdentifier, updateFrequency: import("./types").UpdateFrequency) => Promise<boolean>;
|
|
94
94
|
getBiologicalSex: () => import("./types").BiologicalSex;
|
|
95
95
|
getBloodType: () => import("./types").BloodType;
|
|
96
|
-
getDateOfBirth: () => Date |
|
|
96
|
+
getDateOfBirth: () => Date | undefined;
|
|
97
97
|
getFitzpatrickSkinType: () => import("./types").FitzpatrickSkinType;
|
|
98
98
|
getBiologicalSexAsync: () => Promise<import("./types").BiologicalSex>;
|
|
99
99
|
getBloodTypeAsync: () => Promise<import("./types").BloodType>;
|
|
100
|
-
getDateOfBirthAsync: () => Promise<Date |
|
|
100
|
+
getDateOfBirthAsync: () => Promise<Date | undefined>;
|
|
101
101
|
getFitzpatrickSkinTypeAsync: () => Promise<import("./types").FitzpatrickSkinType>;
|
|
102
102
|
getWheelchairUseAsync: () => Promise<import("./types").WheelchairUse>;
|
|
103
103
|
getMostRecentCategorySample: typeof getMostRecentCategorySample;
|
|
@@ -105,7 +105,7 @@ declare const _default: {
|
|
|
105
105
|
getMostRecentWorkout: () => Promise<import("./specs/WorkoutProxy.nitro").WorkoutProxy | undefined>;
|
|
106
106
|
getPreferredUnits: (identifiers: readonly QuantityTypeIdentifier[], forceUpdate?: boolean) => Promise<import("./types").IdentifierWithUnit[]>;
|
|
107
107
|
getPreferredUnit: (quantityType: QuantityTypeIdentifier) => Promise<string>;
|
|
108
|
-
getRequestStatusForAuthorization: (
|
|
108
|
+
getRequestStatusForAuthorization: (toCheck: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<import("./types").AuthorizationRequestStatus>;
|
|
109
109
|
getWheelchairUse: () => import("./types").WheelchairUse;
|
|
110
110
|
isHealthDataAvailable: () => boolean;
|
|
111
111
|
isHealthDataAvailableAsync: () => Promise<boolean>;
|
|
@@ -119,16 +119,16 @@ declare const _default: {
|
|
|
119
119
|
queryQuantitySamples: (identifier: QuantityTypeIdentifier, options?: import("./types").QueryOptionsWithSortOrderAndUnit) => Promise<readonly import("./types").QuantitySample[]>;
|
|
120
120
|
queryQuantitySamplesWithAnchor: (identifier: QuantityTypeIdentifier, options: import("./types").QueryOptionsWithAnchorAndUnit) => Promise<import("./types").QuantitySamplesWithAnchorResponse>;
|
|
121
121
|
queryStatisticsForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], options?: import("./types").StatisticsQueryOptions) => Promise<import("./types").QueryStatisticsResponse>;
|
|
122
|
-
queryStatisticsCollectionForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate:
|
|
122
|
+
queryStatisticsCollectionForQuantity: (identifier: QuantityTypeIdentifier, statistics: readonly import("./types").StatisticsOptions[], anchorDate: Date, intervalComponents: import("./types").IntervalComponents, options?: import("./types").StatisticsQueryOptions) => Promise<readonly import("./types").QueryStatisticsResponse[]>;
|
|
123
123
|
queryWorkoutSamples: (options: import("./types").WorkoutQueryOptions) => Promise<import("./specs/WorkoutProxy.nitro").WorkoutProxy[]>;
|
|
124
124
|
queryWorkoutSamplesWithAnchor: (options: import("./types").WorkoutQueryOptionsWithAnchor) => Promise<import("./types").QueryWorkoutSamplesWithAnchorResponse>;
|
|
125
125
|
querySources: (identifier: import("./types").SampleTypeIdentifier) => Promise<readonly import("./specs/SourceProxy.nitro").SourceProxy[]>;
|
|
126
|
-
requestAuthorization: (
|
|
126
|
+
requestAuthorization: (toRequest: import("./specs/CoreModule.nitro").AuthDataTypes) => Promise<boolean>;
|
|
127
127
|
deleteObjects: (objectTypeIdentifier: import("./types").ObjectTypeIdentifier, filter: import("./types").FilterForSamples) => Promise<number>;
|
|
128
128
|
saveCategorySample: <T extends import("./types").CategoryTypeIdentifier>(identifier: T, value: import("./types").CategoryValueForIdentifier, startDate: Date, endDate: Date, metadata: import("./types").MetadataForCategoryIdentifier<T>) => Promise<boolean>;
|
|
129
129
|
saveCorrelationSample: (typeIdentifier: import("./types").CorrelationTypeIdentifier, samples: import("./types").SampleForSaving[], start: Date, end: Date, metadata: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
130
130
|
saveQuantitySample: (identifier: QuantityTypeIdentifier, unit: string, value: number, start: Date, end: Date, metadata: import("react-native-nitro-modules").AnyMap) => Promise<boolean>;
|
|
131
|
-
saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals
|
|
131
|
+
saveWorkoutSample: (workoutActivityType: import("./types").WorkoutActivityType, quantities: readonly import("./types").QuantitySampleForSaving[], startDate: Date, endDate: Date, totals?: import("./types").WorkoutTotals, metadata?: import("react-native-nitro-modules").AnyMap) => Promise<import("./specs/WorkoutProxy.nitro").WorkoutProxy>;
|
|
132
132
|
subscribeToChanges: (typeIdentifier: import("./types").SampleTypeIdentifier, callback: (args: import("./types").OnChangeCallbackArgs) => void) => string;
|
|
133
133
|
unsubscribeQueries: (queryIds: string[]) => number;
|
|
134
134
|
startWatchApp: (workoutConfiguration: import("./types").WorkoutConfiguration) => Promise<boolean>;
|
|
@@ -139,7 +139,10 @@ declare const _default: {
|
|
|
139
139
|
useMostRecentQuantitySample: typeof useMostRecentQuantitySample;
|
|
140
140
|
useMostRecentWorkout: typeof useMostRecentWorkout;
|
|
141
141
|
useSubscribeToChanges: typeof useSubscribeToChanges;
|
|
142
|
-
useHealthkitAuthorization: (
|
|
142
|
+
useHealthkitAuthorization: ({ toWrite, toRead, }: {
|
|
143
|
+
toRead?: readonly import("./types").ObjectTypeIdentifier[];
|
|
144
|
+
toWrite?: readonly import("./types").SampleTypeIdentifierWriteable[];
|
|
145
|
+
}) => readonly [import("./types").AuthorizationRequestStatus | null, () => Promise<import("./types").AuthorizationRequestStatus>];
|
|
143
146
|
useIsHealthDataAvailable: () => boolean | null;
|
|
144
147
|
useSources: typeof useSources;
|
|
145
148
|
useStatisticsForQuantity: typeof useStatisticsForQuantity;
|
|
@@ -5,5 +5,8 @@ import type { ObjectTypeIdentifier, SampleTypeIdentifierWriteable } from '../typ
|
|
|
5
5
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}
|
|
6
6
|
* @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}
|
|
7
7
|
*/
|
|
8
|
-
export declare const useHealthkitAuthorization: (
|
|
8
|
+
export declare const useHealthkitAuthorization: ({ toWrite, toRead, }: {
|
|
9
|
+
toRead?: readonly ObjectTypeIdentifier[];
|
|
10
|
+
toWrite?: readonly SampleTypeIdentifierWriteable[];
|
|
11
|
+
}) => readonly [AuthorizationRequestStatus | null, () => Promise<AuthorizationRequestStatus>];
|
|
9
12
|
export default useHealthkitAuthorization;
|
|
@@ -4,12 +4,12 @@ export interface CharacteristicTypeModule extends HybridObject<{
|
|
|
4
4
|
ios: 'swift';
|
|
5
5
|
}> {
|
|
6
6
|
getBloodType(): BloodType;
|
|
7
|
-
getDateOfBirth(): Date |
|
|
7
|
+
getDateOfBirth(): Date | undefined;
|
|
8
8
|
getBiologicalSex(): BiologicalSex;
|
|
9
9
|
getFitzpatrickSkinType(): FitzpatrickSkinType;
|
|
10
10
|
getWheelchairUse(): WheelchairUse;
|
|
11
11
|
getBloodTypeAsync(): Promise<BloodType>;
|
|
12
|
-
getDateOfBirthAsync(): Promise<Date |
|
|
12
|
+
getDateOfBirthAsync(): Promise<Date | undefined>;
|
|
13
13
|
getBiologicalSexAsync(): Promise<BiologicalSex>;
|
|
14
14
|
getFitzpatrickSkinTypeAsync(): Promise<FitzpatrickSkinType>;
|
|
15
15
|
getWheelchairUseAsync(): Promise<WheelchairUse>;
|
|
@@ -7,6 +7,10 @@ import type { ObjectTypeIdentifier, SampleTypeIdentifier, SampleTypeIdentifierWr
|
|
|
7
7
|
import type { OnChangeCallbackArgs } from '../types/Subscriptions';
|
|
8
8
|
import type { IdentifierWithUnit } from '../types/Units';
|
|
9
9
|
import type { SourceProxy } from './SourceProxy.nitro';
|
|
10
|
+
export interface AuthDataTypes {
|
|
11
|
+
toShare?: readonly SampleTypeIdentifierWriteable[];
|
|
12
|
+
toRead?: readonly ObjectTypeIdentifier[];
|
|
13
|
+
}
|
|
10
14
|
export interface CoreModule extends HybridObject<{
|
|
11
15
|
ios: 'swift';
|
|
12
16
|
}> {
|
|
@@ -41,17 +45,18 @@ export interface CoreModule extends HybridObject<{
|
|
|
41
45
|
unsubscribeQueries(queryIds: string[]): number;
|
|
42
46
|
unsubscribeQueriesAsync(queryIds: string[]): Promise<number>;
|
|
43
47
|
/**
|
|
48
|
+
* Returns the app’s authorization status for sharing the specified data type.
|
|
44
49
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus Apple Docs }
|
|
45
50
|
*/
|
|
46
51
|
authorizationStatusFor(type: ObjectTypeIdentifier): AuthorizationStatus;
|
|
47
52
|
/**
|
|
48
53
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/2994346-getrequeststatusforauthorization Apple Docs }
|
|
49
54
|
*/
|
|
50
|
-
getRequestStatusForAuthorization(
|
|
55
|
+
getRequestStatusForAuthorization(toCheck: AuthDataTypes): Promise<AuthorizationRequestStatus>;
|
|
51
56
|
/**
|
|
52
57
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs }
|
|
53
58
|
*/
|
|
54
|
-
requestAuthorization(
|
|
59
|
+
requestAuthorization(toRequest: AuthDataTypes): Promise<boolean>;
|
|
55
60
|
deleteObjects(objectTypeIdentifier: ObjectTypeIdentifier, filter: FilterForSamples): Promise<number>;
|
|
56
61
|
isObjectTypeAvailable(objectTypeIdentifier: ObjectTypeIdentifier): boolean;
|
|
57
62
|
areObjectTypesAvailable(objectTypeIdentifiers: readonly ObjectTypeIdentifier[]): Record<string, boolean>;
|
|
@@ -11,6 +11,6 @@ export interface QuantityTypeModule extends HybridObject<{
|
|
|
11
11
|
deleteQuantitySamples(identifier: QuantityTypeIdentifier, filter: FilterForSamples): Promise<boolean>;
|
|
12
12
|
queryQuantitySamples(identifier: QuantityTypeIdentifier, options?: QueryOptionsWithSortOrderAndUnit): Promise<readonly QuantitySample[]>;
|
|
13
13
|
queryStatisticsForQuantity(identifier: QuantityTypeIdentifier, statistics: readonly StatisticsOptions[], options?: StatisticsQueryOptions): Promise<QueryStatisticsResponse>;
|
|
14
|
-
queryStatisticsCollectionForQuantity(identifier: QuantityTypeIdentifier, statistics: readonly StatisticsOptions[], anchorDate:
|
|
14
|
+
queryStatisticsCollectionForQuantity(identifier: QuantityTypeIdentifier, statistics: readonly StatisticsOptions[], anchorDate: Date, intervalComponents: IntervalComponents, options?: StatisticsQueryOptions): Promise<readonly QueryStatisticsResponse[]>;
|
|
15
15
|
queryQuantitySamplesWithAnchor(identifier: QuantityTypeIdentifier, options: QueryOptionsWithAnchorAndUnit): Promise<QuantitySamplesWithAnchorResponse>;
|
|
16
16
|
}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
2
|
-
import type {
|
|
2
|
+
import type { QuantityTypeIdentifier, QueryStatisticsResponse } from '../types';
|
|
3
3
|
import type { LocationForSaving, WorkoutPlan, WorkoutRoute, WorkoutSample } from '../types/Workouts';
|
|
4
4
|
export interface WorkoutProxy extends HybridObject<{
|
|
5
5
|
ios: 'swift';
|
|
6
6
|
}>, WorkoutSample {
|
|
7
7
|
toJSON(key?: string): WorkoutSample;
|
|
8
8
|
saveWorkoutRoute(locations: readonly LocationForSaving[]): Promise<boolean>;
|
|
9
|
-
getWorkoutPlan(): Promise<WorkoutPlan |
|
|
9
|
+
getWorkoutPlan(): Promise<WorkoutPlan | undefined>;
|
|
10
10
|
getWorkoutRoutes(): Promise<readonly WorkoutRoute[]>;
|
|
11
|
-
getStatistic(quantityType: QuantityTypeIdentifier, unitOverride?: string): Promise<QueryStatisticsResponse |
|
|
11
|
+
getStatistic(quantityType: QuantityTypeIdentifier, unitOverride?: string): Promise<QueryStatisticsResponse | undefined>;
|
|
12
12
|
getAllStatistics(): Promise<Record<string, QueryStatisticsResponse>>;
|
|
13
|
-
/** @deprecated Use allStatistics or statistic() method instead */
|
|
14
|
-
readonly totalDistance?: Quantity;
|
|
15
|
-
/** @deprecated Use allStatistics or statistic() method instead */
|
|
16
|
-
readonly totalEnergyBurned?: Quantity;
|
|
17
|
-
/** @deprecated Use allStatistics or statistic() method instead */
|
|
18
|
-
readonly totalSwimmingStrokeCount?: Quantity;
|
|
19
|
-
/** @deprecated Use allStatistics or statistic() method instead */
|
|
20
|
-
readonly totalFlightsClimbed?: Quantity;
|
|
21
13
|
}
|
|
@@ -6,7 +6,7 @@ import type { WorkoutProxy } from './WorkoutProxy.nitro';
|
|
|
6
6
|
export interface WorkoutsModule extends HybridObject<{
|
|
7
7
|
ios: 'swift';
|
|
8
8
|
}> {
|
|
9
|
-
saveWorkoutSample(workoutActivityType: WorkoutActivityType, quantities: readonly QuantitySampleForSaving[], startDate: Date, endDate: Date, totals
|
|
9
|
+
saveWorkoutSample(workoutActivityType: WorkoutActivityType, quantities: readonly QuantitySampleForSaving[], startDate: Date, endDate: Date, totals?: WorkoutTotals, metadata?: AnyMap): Promise<WorkoutProxy>;
|
|
10
10
|
queryWorkoutSamplesWithAnchor(options: WorkoutQueryOptionsWithAnchor): Promise<QueryWorkoutSamplesWithAnchorResponse>;
|
|
11
11
|
queryWorkoutSamples(options: WorkoutQueryOptions): Promise<WorkoutProxy[]>;
|
|
12
12
|
/**
|