@kingstinct/react-native-healthkit 7.0.6 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ReactNativeHealthkit.swift +68 -2
- package/lib/commonjs/native-types.js +33 -6
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/module/native-types.js +29 -2
- package/lib/module/native-types.js.map +1 -1
- package/lib/typescript/src/native-types.d.ts +68 -4
- package/package.json +1 -1
- package/src/native-types.ts +77 -12
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import HealthKit
|
|
2
2
|
import CoreLocation
|
|
3
3
|
|
|
4
|
+
#if canImport(WorkoutKit)
|
|
5
|
+
import WorkoutKit
|
|
6
|
+
#endif
|
|
7
|
+
|
|
4
8
|
@objc(ReactNativeHealthkit)
|
|
5
9
|
@available(iOS 10.0, *)
|
|
6
10
|
class ReactNativeHealthkit: RCTEventEmitter {
|
|
@@ -504,6 +508,8 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
504
508
|
store.execute(query)
|
|
505
509
|
|
|
506
510
|
self._runningQueries.updateValue(query, forKey: queryId)
|
|
511
|
+
|
|
512
|
+
resolve(queryId)
|
|
507
513
|
}
|
|
508
514
|
|
|
509
515
|
@objc(unsubscribeQuery:resolve:reject:)
|
|
@@ -617,6 +623,7 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
617
623
|
|
|
618
624
|
@objc(queryWorkoutSamples:distanceUnitString:from:to:limit:ascending:resolve:reject:)
|
|
619
625
|
func queryWorkoutSamples(energyUnitString: String, distanceUnitString: String, from: Date, to: Date, limit: Int, ascending: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
626
|
+
|
|
620
627
|
guard let store = _store else {
|
|
621
628
|
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil)
|
|
622
629
|
}
|
|
@@ -656,11 +663,70 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
656
663
|
"metadata": serializeMetadata(metadata: workout.metadata),
|
|
657
664
|
"sourceRevision": serializeSourceRevision(_sourceRevision: workout.sourceRevision) as Any
|
|
658
665
|
]
|
|
659
|
-
|
|
666
|
+
|
|
667
|
+
//this is used for our laps functionality to get markers
|
|
668
|
+
//https://developer.apple.com/documentation/healthkit/hkworkoutevent
|
|
669
|
+
var eventArray: [[String: Any]] = []
|
|
670
|
+
if let events = workout.workoutEvents {
|
|
671
|
+
for event in events {
|
|
672
|
+
let eventStartDate = self._dateFormatter.string(from: event.dateInterval.start)
|
|
673
|
+
let eventEndDate = self._dateFormatter.string(from: event.dateInterval.end)
|
|
674
|
+
let eventDict: [String: Any] = [
|
|
675
|
+
"type": event.type.rawValue, //https://developer.apple.com/documentation/healthkit/hkworkouteventtype
|
|
676
|
+
"startDate": eventStartDate,
|
|
677
|
+
"endDate": eventEndDate
|
|
678
|
+
]
|
|
679
|
+
eventArray.append(eventDict)
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
dict["events"] = eventArray
|
|
683
|
+
|
|
684
|
+
//also used for our laps functionality to get activities for custom workouts defined by the user
|
|
685
|
+
//https://developer.apple.com/documentation/healthkit/hkworkout/1615340-init
|
|
686
|
+
//it seems this might be depricated in the latest beta so this might need updating!
|
|
687
|
+
var activitiesArray: [[String: Any]] = []
|
|
688
|
+
if #available(iOS 16.0, *) {
|
|
689
|
+
let activities: [HKWorkoutActivity] = workout.workoutActivities
|
|
690
|
+
|
|
691
|
+
if !activities.isEmpty{
|
|
692
|
+
for activity in activities {
|
|
693
|
+
var activityStartDate = ""
|
|
694
|
+
var activityEndDate = ""
|
|
695
|
+
if let start = activity.startDate as Date? {
|
|
696
|
+
activityStartDate = self._dateFormatter.string(from: activity.startDate)
|
|
697
|
+
}
|
|
698
|
+
if let end = activity.endDate as Date? {
|
|
699
|
+
activityEndDate = self._dateFormatter.string(from: activity.endDate!)
|
|
700
|
+
}
|
|
701
|
+
let activityDict: [String: Any] = [
|
|
702
|
+
"startDate": activityStartDate,
|
|
703
|
+
"endDate": activityEndDate,
|
|
704
|
+
"uuid": activity.uuid.uuidString,
|
|
705
|
+
"duration": activity.duration
|
|
706
|
+
]
|
|
707
|
+
activitiesArray.append(activityDict)
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
dict["activities"] = activitiesArray
|
|
712
|
+
|
|
660
713
|
if #available(iOS 11, *) {
|
|
661
714
|
dict.setValue(serializeQuantity(unit: HKUnit.count(), quantity: workout.totalFlightsClimbed), forKey: "totalFlightsClimbed")
|
|
662
715
|
}
|
|
663
|
-
|
|
716
|
+
|
|
717
|
+
#if canImport(WorkoutKit)
|
|
718
|
+
if #available(iOS 17.0, *) {
|
|
719
|
+
do {
|
|
720
|
+
let workoutplan = try await workout.workoutPlan
|
|
721
|
+
if let workoutplanId = workoutplan?.id {
|
|
722
|
+
dict["workoutPlanId"] = workoutplanId.uuidString
|
|
723
|
+
}
|
|
724
|
+
} catch {
|
|
725
|
+
// handle error
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
#endif
|
|
729
|
+
|
|
664
730
|
arr.add(dict)
|
|
665
731
|
}
|
|
666
732
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = exports.UnitOfVolume = exports.UnitOfTime = exports.UnitOfPressure = exports.UnitOfMass = exports.UnitOfLength = exports.UnitOfEnergy = exports.TemperatureUnit = exports.HKWorkoutTypeIdentifier = exports.HKWorkoutRouteTypeIdentifier = exports.HKWorkoutActivityType = exports.HKWheelchairUse = exports.HKWeatherCondition = exports.HKUpdateFrequency = exports.HKUnits = exports.HKUnitMetric = exports.HKStatisticsOptions = exports.HKQuantityTypeIdentifier = exports.HKMetricPrefix = exports.HKInsulinDeliveryReason = exports.HKHeartRateMotionContext = exports.HKFitzpatrickSkinType = exports.
|
|
6
|
+
exports.default = exports.UnitOfVolume = exports.UnitOfTime = exports.UnitOfPressure = exports.UnitOfMass = exports.UnitOfLength = exports.UnitOfEnergy = exports.TemperatureUnit = exports.HKWorkoutTypeIdentifier = exports.HKWorkoutRouteTypeIdentifier = exports.HKWorkoutEventType = exports.HKWorkoutActivityType = exports.HKWheelchairUse = exports.HKWeatherCondition = exports.HKUpdateFrequency = exports.HKUnits = exports.HKUnitMetric = exports.HKStatisticsOptions = exports.HKQuantityTypeIdentifier = exports.HKMetricPrefix = exports.HKInsulinDeliveryReason = exports.HKHeartRateMotionContext = exports.HKFitzpatrickSkinType = exports.HKCorrelationTypeIdentifier = exports.HKCharacteristicTypeIdentifier = exports.HKCategoryValueSleepAnalysis = exports.HKCategoryValueSeverity = exports.HKCategoryValuePresence = exports.HKCategoryValueOvulationTestResult = exports.HKCategoryValueNotApplicable = exports.HKCategoryValueMenstrualFlow = exports.HKCategoryValueLowCardioFitnessEvent = exports.HKCategoryValueCervicalMucusQuality = exports.HKCategoryValueAppleStandHour = exports.HKCategoryValueAppetiteChanges = exports.HKCategoryTypeIdentifier = exports.HKBloodType = exports.HKBiologicalSex = exports.HKAuthorizationStatus = exports.HKAuthorizationRequestStatus = exports.HKAudiogramTypeIdentifier = exports.HKActivitySummaryType = exports.EventEmitter = exports.BloodGlucoseUnit = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
/**
|
|
9
9
|
* Represents a workout type identifier.
|
|
@@ -12,10 +12,18 @@ var _reactNative = require("react-native");
|
|
|
12
12
|
const HKWorkoutTypeIdentifier = 'HKWorkoutTypeIdentifier';
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* Represents
|
|
15
|
+
* Represents a type that identifies activity summary objects.
|
|
16
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/hkactivitysummarytype Apple Docs HKActivitySummaryType}
|
|
16
17
|
*/
|
|
17
18
|
exports.HKWorkoutTypeIdentifier = HKWorkoutTypeIdentifier;
|
|
18
|
-
const
|
|
19
|
+
const HKActivitySummaryType = 'HKActivitySummaryType';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Represents an audiogram type identifier.
|
|
23
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKAudiogramSampleType Apple Docs HKAudiogramSampleType}
|
|
24
|
+
*/
|
|
25
|
+
exports.HKActivitySummaryType = HKActivitySummaryType;
|
|
26
|
+
const HKAudiogramTypeIdentifier = 'HKAudiogramSampleType';
|
|
19
27
|
|
|
20
28
|
/**
|
|
21
29
|
* Represents a workout route type identifier.
|
|
@@ -23,14 +31,16 @@ const HKAudiogramTypeIdentifier = 'HKAudiogramTypeIdentifier';
|
|
|
23
31
|
*/
|
|
24
32
|
exports.HKAudiogramTypeIdentifier = HKAudiogramTypeIdentifier;
|
|
25
33
|
const HKWorkoutRouteTypeIdentifier = 'HKWorkoutRouteTypeIdentifier';
|
|
26
|
-
exports.HKWorkoutRouteTypeIdentifier = HKWorkoutRouteTypeIdentifier;
|
|
27
|
-
const HKDataTypeIdentifierHeartbeatSeries = 'HKDataTypeIdentifierHeartbeatSeries';
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Represents a series sample containing heartbeat data..
|
|
37
|
+
* @see {@link https://developer.apple.com/documentation/healthkit/HKDataTypeIdentifierHeartbeatSeries Apple Docs HKDataTypeIdentifierHeartbeatSeries}
|
|
38
|
+
*/
|
|
39
|
+
exports.HKWorkoutRouteTypeIdentifier = HKWorkoutRouteTypeIdentifier;
|
|
29
40
|
/**
|
|
30
41
|
* Represents a quantity type identifier.
|
|
31
42
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitytypeidentifier Apple Docs HKQuantityTypeIdentifier}
|
|
32
43
|
*/
|
|
33
|
-
exports.HKDataTypeIdentifierHeartbeatSeries = HKDataTypeIdentifierHeartbeatSeries;
|
|
34
44
|
let HKQuantityTypeIdentifier = /*#__PURE__*/function (HKQuantityTypeIdentifier) {
|
|
35
45
|
HKQuantityTypeIdentifier["bodyMassIndex"] = "HKQuantityTypeIdentifierBodyMassIndex";
|
|
36
46
|
HKQuantityTypeIdentifier["bodyFatPercentage"] = "HKQuantityTypeIdentifierBodyFatPercentage";
|
|
@@ -137,6 +147,11 @@ let HKQuantityTypeIdentifier = /*#__PURE__*/function (HKQuantityTypeIdentifier)
|
|
|
137
147
|
HKQuantityTypeIdentifier["cyclingCadence"] = "HKQuantityTypeIdentifierCyclingCadence";
|
|
138
148
|
HKQuantityTypeIdentifier["environmentalSoundReduction"] = "HKQuantityTypeIdentifierEnvironmentalSoundReduction";
|
|
139
149
|
HKQuantityTypeIdentifier["heartRateRecoveryOneMinute"] = "HKQuantityTypeIdentifierHeartRateRecoveryOneMinute";
|
|
150
|
+
HKQuantityTypeIdentifier["runningGroundContactTime"] = "HKQuantityTypeIdentifierRunningGroundContactTime";
|
|
151
|
+
HKQuantityTypeIdentifier["runningStrideLength"] = "HKQuantityTypeIdentifierRunningStrideLength";
|
|
152
|
+
HKQuantityTypeIdentifier["runningPower"] = "HKQuantityTypeIdentifierRunningPower";
|
|
153
|
+
HKQuantityTypeIdentifier["runningVerticalOscillation"] = "HKQuantityTypeIdentifierRunningVerticalOscillation";
|
|
154
|
+
HKQuantityTypeIdentifier["runningSpeed"] = "HKQuantityTypeIdentifierRunningSpeed";
|
|
140
155
|
return HKQuantityTypeIdentifier;
|
|
141
156
|
}({});
|
|
142
157
|
exports.HKQuantityTypeIdentifier = HKQuantityTypeIdentifier;
|
|
@@ -715,6 +730,18 @@ let BloodGlucoseUnit = /*#__PURE__*/function (BloodGlucoseUnit) {
|
|
|
715
730
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkquantitysample Apple Docs }
|
|
716
731
|
*/
|
|
717
732
|
exports.BloodGlucoseUnit = BloodGlucoseUnit;
|
|
733
|
+
let HKWorkoutEventType = /*#__PURE__*/function (HKWorkoutEventType) {
|
|
734
|
+
HKWorkoutEventType[HKWorkoutEventType["pause"] = 1] = "pause";
|
|
735
|
+
HKWorkoutEventType[HKWorkoutEventType["resume"] = 2] = "resume";
|
|
736
|
+
HKWorkoutEventType[HKWorkoutEventType["lap"] = 3] = "lap";
|
|
737
|
+
HKWorkoutEventType[HKWorkoutEventType["marker"] = 4] = "marker";
|
|
738
|
+
HKWorkoutEventType[HKWorkoutEventType["motionPaused"] = 5] = "motionPaused";
|
|
739
|
+
HKWorkoutEventType[HKWorkoutEventType["motionResumed"] = 6] = "motionResumed";
|
|
740
|
+
HKWorkoutEventType[HKWorkoutEventType["segment"] = 7] = "segment";
|
|
741
|
+
HKWorkoutEventType[HKWorkoutEventType["pauseOrResumeRequest"] = 8] = "pauseOrResumeRequest";
|
|
742
|
+
return HKWorkoutEventType;
|
|
743
|
+
}({});
|
|
744
|
+
exports.HKWorkoutEventType = HKWorkoutEventType;
|
|
718
745
|
// Straight mapping to https://developer.apple.com/documentation/healthkit/hkcharacteristictypeidentifier
|
|
719
746
|
let HKCharacteristicTypeIdentifier = /*#__PURE__*/function (HKCharacteristicTypeIdentifier) {
|
|
720
747
|
HKCharacteristicTypeIdentifier["fitzpatrickSkinType"] = "HKCharacteristicTypeIdentifierFitzpatrickSkinType";
|