@kingstinct/react-native-healthkit 7.1.1 → 7.3.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 -1
- package/ios/Helpers.swift +6 -0
- package/ios/ReactNativeHealthkit.m +8 -1
- package/ios/ReactNativeHealthkit.swift +204 -74
- package/lib/commonjs/index.ios.js +4 -0
- package/lib/commonjs/index.ios.js.map +1 -1
- package/lib/commonjs/index.js +3 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/jest.setup.js +3 -1
- package/lib/commonjs/jest.setup.js.map +1 -1
- package/lib/commonjs/native-types.js +5 -5
- package/lib/commonjs/native-types.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/ensureTotals.js +12 -0
- package/lib/commonjs/utils/ensureTotals.js.map +1 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js +14 -0
- package/lib/commonjs/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/commonjs/utils/saveCorrelationSample.js +20 -4
- package/lib/commonjs/utils/saveCorrelationSample.js.map +1 -1
- package/lib/commonjs/utils/saveWorkoutRoute.js +27 -0
- package/lib/commonjs/utils/saveWorkoutRoute.js.map +1 -0
- package/lib/commonjs/utils/saveWorkoutSample.js +21 -4
- package/lib/commonjs/utils/saveWorkoutSample.js.map +1 -1
- package/lib/module/index.ios.js +4 -0
- package/lib/module/index.ios.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/jest.setup.js +3 -1
- package/lib/module/jest.setup.js.map +1 -1
- package/lib/module/native-types.js +3 -3
- package/lib/module/native-types.js.map +1 -1
- package/lib/module/types.js +5 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/ensureTotals.js +5 -0
- package/lib/module/utils/ensureTotals.js.map +1 -0
- package/lib/module/utils/getWorkoutPlanById.js +6 -0
- package/lib/module/utils/getWorkoutPlanById.js.map +1 -0
- package/lib/module/utils/saveCorrelationSample.js +20 -4
- package/lib/module/utils/saveCorrelationSample.js.map +1 -1
- package/lib/module/utils/saveWorkoutRoute.js +19 -0
- package/lib/module/utils/saveWorkoutRoute.js.map +1 -0
- package/lib/module/utils/saveWorkoutSample.js +21 -4
- package/lib/module/utils/saveWorkoutSample.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.ios.d.ts +4 -0
- package/lib/typescript/src/native-types.d.ts +102 -78
- package/lib/typescript/src/types.d.ts +16 -3
- package/lib/typescript/src/utils/ensureTotals.d.ts +2 -0
- package/lib/typescript/src/utils/getWorkoutPlanById.d.ts +5 -0
- package/lib/typescript/src/utils/saveWorkoutRoute.d.ts +3 -0
- package/lib/typescript/src/utils/saveWorkoutSample.d.ts +5 -1
- package/package.json +1 -1
- package/src/index.ios.tsx +4 -0
- package/src/index.tsx +3 -1
- package/src/jest.setup.ts +3 -1
- package/src/native-types.ts +158 -114
- package/src/types.ts +17 -2
- package/src/utils/ensureTotals.ts +5 -0
- package/src/utils/getWorkoutPlanById.ts +7 -0
- package/src/utils/saveCorrelationSample.ts +10 -1
- package/src/utils/saveWorkoutRoute.ts +21 -0
- package/src/utils/saveWorkoutSample.ts +15 -1
package/ios/Constants.swift
CHANGED
|
@@ -25,4 +25,4 @@ let HKDataTypeIdentifierHeartbeatSeries = "HKDataTypeIdentifierHeartbeatSeries"
|
|
|
25
25
|
|
|
26
26
|
let SpeedUnit = HKUnit(from: "m/s") // HKUnit.meter().unitDivided(by: HKUnit.second())
|
|
27
27
|
// Support for MET data: HKAverageMETs 8.24046 kcal/hr·kg
|
|
28
|
-
let METUnit = HKUnit(from: "kcal/hr·kg")
|
|
28
|
+
let METUnit = HKUnit(from: "kcal/hr·kg")
|
package/ios/Helpers.swift
CHANGED
|
@@ -74,6 +74,12 @@ func sampleTypeFromString(typeIdentifier: String) -> HKSampleType? {
|
|
|
74
74
|
return HKSampleType.workoutType()
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
if #available(iOS 11.0, *) {
|
|
78
|
+
if typeIdentifier == HKWorkoutRouteTypeIdentifier {
|
|
79
|
+
return HKObjectType.seriesType(forIdentifier: typeIdentifier)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
return nil
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -146,11 +146,18 @@ RCT_EXTERN_METHOD(saveWorkoutSample:(NSInteger)typeIdentifier
|
|
|
146
146
|
quantities:(NSArray)quantities
|
|
147
147
|
start:(NSDate)start
|
|
148
148
|
end:(NSDate)end
|
|
149
|
+
totals:(NSDictionary)totals
|
|
149
150
|
metadata:(NSDictionary)metadata
|
|
150
151
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
151
152
|
reject:(RCTPromiseRejectBlock)reject
|
|
152
153
|
)
|
|
153
154
|
|
|
155
|
+
RCT_EXTERN_METHOD(saveWorkoutRoute:(NSString)workoutUUID
|
|
156
|
+
locations:(NSArray)locations
|
|
157
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
158
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
159
|
+
)
|
|
160
|
+
|
|
154
161
|
RCT_EXTERN_METHOD(queryCorrelationSamples:(NSString)typeIdentifier
|
|
155
162
|
from:(NSDate)from
|
|
156
163
|
to:(NSDate)to
|
|
@@ -205,7 +212,7 @@ RCT_EXTERN_METHOD(getWorkoutRoutes:(NSString)workoutUUID
|
|
|
205
212
|
reject:(RCTPromiseRejectBlock)reject
|
|
206
213
|
)
|
|
207
214
|
|
|
208
|
-
RCT_EXTERN_METHOD(
|
|
215
|
+
RCT_EXTERN_METHOD(getWorkoutPlanById:(NSString)workoutUUID
|
|
209
216
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
210
217
|
reject:(RCTPromiseRejectBlock)reject
|
|
211
218
|
)
|
|
@@ -16,7 +16,7 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
16
16
|
override init() {
|
|
17
17
|
self._runningQueries = [String: HKQuery]()
|
|
18
18
|
self._dateFormatter = ISO8601DateFormatter()
|
|
19
|
-
|
|
19
|
+
self._dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
|
|
20
20
|
if HKHealthStore.isHealthDataAvailable() {
|
|
21
21
|
self._store = HKHealthStore.init()
|
|
22
22
|
}
|
|
@@ -25,18 +25,18 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
25
25
|
|
|
26
26
|
deinit {
|
|
27
27
|
if let store = _store {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
for query in self._runningQueries {
|
|
29
|
+
store.stop(query.value)
|
|
30
|
+
}
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
override func stopObserving() {
|
|
35
35
|
self._hasListeners = false
|
|
36
36
|
if let store = _store {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
for query in self._runningQueries {
|
|
38
|
+
store.stop(query.value)
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -126,7 +126,7 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
126
126
|
|
|
127
127
|
do {
|
|
128
128
|
let dateOfBirth = try store.dateOfBirthComponents()
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
resolve(_dateFormatter.string(from: dateOfBirth.date!))
|
|
131
131
|
} catch {
|
|
132
132
|
reject(GENERIC_ERROR, error.localizedDescription, error)
|
|
@@ -292,14 +292,13 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
292
292
|
initializedSamples.insert(quantitySample)
|
|
293
293
|
}
|
|
294
294
|
} else if sample.keys.contains("categoryType") {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
}
|
|
295
|
+
let typeId = HKCategoryTypeIdentifier.init(rawValue: sample["categoryType"] as! String)
|
|
296
|
+
if let type = HKSampleType.categoryType(forIdentifier: typeId) {
|
|
297
|
+
let value = sample["value"] as! Int
|
|
298
|
+
let metadata = sample["metadata"] as? [String: Any]
|
|
299
|
+
let categorySample = HKCategorySample.init(type: type, value: value, start: start, end: end, metadata: metadata)
|
|
300
|
+
initializedSamples.insert(categorySample)
|
|
301
|
+
}
|
|
303
302
|
}
|
|
304
303
|
|
|
305
304
|
}
|
|
@@ -314,14 +313,21 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
314
313
|
}
|
|
315
314
|
}
|
|
316
315
|
|
|
317
|
-
@objc(saveWorkoutSample:quantities:start:end:metadata:resolve:reject:)
|
|
318
|
-
func saveWorkoutSample(typeIdentifier: UInt, quantities: [[String: Any]], start: Date, end: Date, metadata: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
316
|
+
@objc(saveWorkoutSample:quantities:start:end:totals:metadata:resolve:reject:)
|
|
317
|
+
func saveWorkoutSample(typeIdentifier: UInt, quantities: [[String: Any]], start: Date, end: Date, totals: [String: Any], metadata: [String: Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
319
318
|
guard let store = _store else {
|
|
320
319
|
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil)
|
|
321
320
|
}
|
|
322
321
|
|
|
323
322
|
guard let type = HKWorkoutActivityType.init(rawValue: typeIdentifier) else {
|
|
324
|
-
|
|
323
|
+
return reject(TYPE_IDENTIFIER_ERROR, "Failed to initialize HKWorkoutActivityType " + typeIdentifier.description, nil)
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// if start and end both exist, ensure that start date is before end date
|
|
327
|
+
if let startDate = start as Date?, let endDate = end as Date? {
|
|
328
|
+
if startDate > endDate {
|
|
329
|
+
return reject(GENERIC_ERROR, "Start date must be before end date", nil)
|
|
330
|
+
}
|
|
325
331
|
}
|
|
326
332
|
|
|
327
333
|
var initializedSamples = [HKSample]()
|
|
@@ -329,16 +335,18 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
329
335
|
var totalDistance: HKQuantity?
|
|
330
336
|
var totalSwimmingStrokeCount: HKQuantity?
|
|
331
337
|
var totalFlightsClimbed: HKQuantity?
|
|
332
|
-
|
|
338
|
+
// generating quantity samples
|
|
333
339
|
for quantity in quantities {
|
|
334
340
|
let typeId = HKQuantityTypeIdentifier.init(rawValue: quantity["quantityType"] as! String)
|
|
335
341
|
if let type = HKSampleType.quantityType(forIdentifier: typeId) {
|
|
336
342
|
let unitStr = quantity["unit"] as! String
|
|
337
343
|
let quantityVal = quantity["quantity"] as! Double
|
|
338
344
|
let metadata = quantity["metadata"] as? [String: Any]
|
|
339
|
-
|
|
345
|
+
let quantityStart = quantity["startDate"] as? String
|
|
346
|
+
let quantityEnd = quantity["endDate"] as? String
|
|
340
347
|
let unit = HKUnit.init(from: unitStr)
|
|
341
348
|
let quantity = HKQuantity.init(unit: unit, doubleValue: quantityVal)
|
|
349
|
+
|
|
342
350
|
if quantity.is(compatibleWith: HKUnit.kilocalorie()) {
|
|
343
351
|
totalEnergyBurned = quantity
|
|
344
352
|
}
|
|
@@ -351,43 +359,128 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
351
359
|
if typeId == HKQuantityTypeIdentifier.flightsClimbed {
|
|
352
360
|
totalFlightsClimbed = quantity
|
|
353
361
|
}
|
|
354
|
-
let
|
|
355
|
-
|
|
362
|
+
if let quantityStart, let quantityEnd {
|
|
363
|
+
let quantityStartDate = self._dateFormatter.date(from: quantityStart) ?? start
|
|
364
|
+
let quantityEndDate = self._dateFormatter.date(from: quantityEnd) ?? end
|
|
365
|
+
let quantitySample = HKQuantitySample.init(type: type, quantity: quantity, start: quantityStartDate, end: quantityEndDate, metadata: metadata)
|
|
366
|
+
initializedSamples.append(quantitySample)
|
|
367
|
+
} else {
|
|
368
|
+
// Handle the case where either startDate or endDate is nil
|
|
369
|
+
let quantitySample = HKQuantitySample.init(type: type, quantity: quantity, start: start, end: end, metadata: metadata)
|
|
370
|
+
initializedSamples.append(quantitySample)
|
|
371
|
+
}
|
|
356
372
|
}
|
|
357
373
|
}
|
|
358
374
|
|
|
375
|
+
// if totals are provided override samples
|
|
376
|
+
let rawTotalDistance = totals["distance"] as? Double ?? 0.0
|
|
377
|
+
let rawTotalEnergy = totals["energyBurned"] as? Double ?? 0.0
|
|
378
|
+
|
|
379
|
+
if rawTotalDistance != 0.0 {
|
|
380
|
+
totalDistance = HKQuantity(unit: .meter(), doubleValue: rawTotalDistance)
|
|
381
|
+
}
|
|
382
|
+
if rawTotalEnergy != 0.0 {
|
|
383
|
+
totalEnergyBurned = HKQuantity(unit: .kilocalorie(), doubleValue: rawTotalEnergy)
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// creating workout
|
|
359
387
|
var workout: HKWorkout?
|
|
360
388
|
|
|
361
389
|
if totalSwimmingStrokeCount != nil {
|
|
362
390
|
workout = HKWorkout.init(activityType: type, start: start, end: end, workoutEvents: nil, totalEnergyBurned: totalEnergyBurned, totalDistance: totalDistance, totalSwimmingStrokeCount: totalSwimmingStrokeCount, device: nil, metadata: metadata)
|
|
363
391
|
} else {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
392
|
+
if #available(iOS 11, *) {
|
|
393
|
+
if totalFlightsClimbed != nil {
|
|
394
|
+
workout = HKWorkout.init(activityType: type, start: start, end: end, workoutEvents: nil, totalEnergyBurned: totalEnergyBurned, totalDistance: totalDistance, totalFlightsClimbed: totalFlightsClimbed, device: nil, metadata: metadata)
|
|
368
395
|
}
|
|
396
|
+
}
|
|
369
397
|
}
|
|
370
398
|
|
|
371
399
|
if workout == nil {
|
|
372
400
|
workout = HKWorkout.init(activityType: type, start: start, end: end, workoutEvents: nil, totalEnergyBurned: totalEnergyBurned, totalDistance: totalDistance, metadata: metadata)
|
|
373
401
|
}
|
|
374
402
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
403
|
+
guard let workout = workout else {
|
|
404
|
+
reject(GENERIC_ERROR, "Could not create workout", nil)
|
|
405
|
+
return
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// saving workout, samples and route
|
|
409
|
+
store.save(workout) { (_: Bool, error: Error?) in
|
|
410
|
+
guard error == nil else {
|
|
411
|
+
reject(GENERIC_ERROR, error!.localizedDescription, error)
|
|
412
|
+
return
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
if initializedSamples.isEmpty {
|
|
416
|
+
return resolve(workout.uuid.uuidString)
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
store.add(initializedSamples, to: workout) { (_, error: Error?) in
|
|
420
|
+
guard error == nil else {
|
|
421
|
+
reject(GENERIC_ERROR, error!.localizedDescription, error)
|
|
384
422
|
return
|
|
385
423
|
}
|
|
386
|
-
return resolve(
|
|
424
|
+
return resolve(workout.uuid.uuidString)
|
|
387
425
|
}
|
|
388
|
-
reject(GENERIC_ERROR, err.localizedDescription, error)
|
|
389
426
|
}
|
|
427
|
+
}
|
|
390
428
|
|
|
429
|
+
// function which will take an array of location in string format and create an array of CLLocations
|
|
430
|
+
func _createCLLocations(from locations: [[String: Any]]) -> [CLLocation] {
|
|
431
|
+
var clLocations: [CLLocation] = []
|
|
432
|
+
for location in locations {
|
|
433
|
+
guard let latitude = location["latitude"] as? CLLocationDegrees,
|
|
434
|
+
let longitude = location["longitude"] as? CLLocationDegrees,
|
|
435
|
+
let altitude = location["altitude"] as? CLLocationDistance,
|
|
436
|
+
let horizontalAccuracy = location["horizontalAccuracy"] as? CLLocationAccuracy,
|
|
437
|
+
let verticalAccuracy = location["verticalAccuracy"] as? CLLocationAccuracy,
|
|
438
|
+
let course = location["course"] as? CLLocationDirection,
|
|
439
|
+
let speed = location["speed"] as? CLLocationSpeed,
|
|
440
|
+
let timestamp = location["timestamp"] as? String else {
|
|
441
|
+
continue
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
let date = self._dateFormatter.date(from: timestamp) ?? Date()
|
|
445
|
+
let clLocation = CLLocation(coordinate: CLLocationCoordinate2D(latitude: latitude, longitude: longitude), altitude: altitude, horizontalAccuracy: horizontalAccuracy, verticalAccuracy: verticalAccuracy, course: course, speed: speed, timestamp: date)
|
|
446
|
+
clLocations.append(clLocation)
|
|
447
|
+
}
|
|
448
|
+
return clLocations
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
@available(iOS 13.0.0, *)
|
|
452
|
+
@objc(saveWorkoutRoute:locations:resolve:reject:)
|
|
453
|
+
func saveWorkoutRoute(workoutUUID: String, locations: [[String: Any]], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
454
|
+
guard let store = _store else {
|
|
455
|
+
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil)
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
Task {
|
|
459
|
+
if let uuid = UUID(uuidString: workoutUUID) {
|
|
460
|
+
do {
|
|
461
|
+
let workout = await self.getWorkoutByID(store: store, workoutUUID: uuid)
|
|
462
|
+
if let workout {
|
|
463
|
+
// create CLLocations and return if locations are empty
|
|
464
|
+
let clLocations = self._createCLLocations(from: locations)
|
|
465
|
+
if clLocations.isEmpty {
|
|
466
|
+
return reject(GENERIC_ERROR, "No locations provided", nil)
|
|
467
|
+
}
|
|
468
|
+
// create route
|
|
469
|
+
let routeBuilder = HKWorkoutRouteBuilder(healthStore: store, device: nil)
|
|
470
|
+
try await routeBuilder.insertRouteData(clLocations)
|
|
471
|
+
try await routeBuilder.finishRoute(with: workout, metadata: nil)
|
|
472
|
+
|
|
473
|
+
return resolve(true)
|
|
474
|
+
} else {
|
|
475
|
+
return reject(GENERIC_ERROR, "No workout found", nil)
|
|
476
|
+
}
|
|
477
|
+
} catch {
|
|
478
|
+
return reject(GENERIC_ERROR, error.localizedDescription, error)
|
|
479
|
+
}
|
|
480
|
+
} else {
|
|
481
|
+
return reject(GENERIC_ERROR, "Invalid UUID", nil)
|
|
482
|
+
}
|
|
483
|
+
}
|
|
391
484
|
}
|
|
392
485
|
|
|
393
486
|
@objc(saveCategorySample:value:start:end:metadata:resolve:reject:)
|
|
@@ -623,7 +716,6 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
623
716
|
|
|
624
717
|
@objc(queryWorkoutSamples:distanceUnitString:from:to:limit:ascending:resolve:reject:)
|
|
625
718
|
func queryWorkoutSamples(energyUnitString: String, distanceUnitString: String, from: Date, to: Date, limit: Int, ascending: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
626
|
-
|
|
627
719
|
guard let store = _store else {
|
|
628
720
|
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil)
|
|
629
721
|
}
|
|
@@ -663,16 +755,16 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
663
755
|
"metadata": serializeMetadata(metadata: workout.metadata),
|
|
664
756
|
"sourceRevision": serializeSourceRevision(_sourceRevision: workout.sourceRevision) as Any
|
|
665
757
|
]
|
|
666
|
-
|
|
667
|
-
//this is used for our laps functionality to get markers
|
|
668
|
-
//https://developer.apple.com/documentation/healthkit/hkworkoutevent
|
|
758
|
+
|
|
759
|
+
// this is used for our laps functionality to get markers
|
|
760
|
+
// https://developer.apple.com/documentation/healthkit/hkworkoutevent
|
|
669
761
|
var eventArray: [[String: Any]] = []
|
|
670
762
|
if let events = workout.workoutEvents {
|
|
671
763
|
for event in events {
|
|
672
764
|
let eventStartDate = self._dateFormatter.string(from: event.dateInterval.start)
|
|
673
765
|
let eventEndDate = self._dateFormatter.string(from: event.dateInterval.end)
|
|
674
766
|
let eventDict: [String: Any] = [
|
|
675
|
-
"type": event.type.rawValue, //https://developer.apple.com/documentation/healthkit/hkworkouteventtype
|
|
767
|
+
"type": event.type.rawValue, // https://developer.apple.com/documentation/healthkit/hkworkouteventtype
|
|
676
768
|
"startDate": eventStartDate,
|
|
677
769
|
"endDate": eventEndDate
|
|
678
770
|
]
|
|
@@ -680,23 +772,23 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
680
772
|
}
|
|
681
773
|
}
|
|
682
774
|
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!
|
|
775
|
+
|
|
776
|
+
// also used for our laps functionality to get activities for custom workouts defined by the user
|
|
777
|
+
// https://developer.apple.com/documentation/healthkit/hkworkout/1615340-init
|
|
778
|
+
// it seems this might be depricated in the latest beta so this might need updating!
|
|
687
779
|
var activitiesArray: [[String: Any]] = []
|
|
688
780
|
if #available(iOS 16.0, *) {
|
|
689
781
|
let activities: [HKWorkoutActivity] = workout.workoutActivities
|
|
690
|
-
|
|
691
|
-
if !activities.isEmpty{
|
|
782
|
+
|
|
783
|
+
if !activities.isEmpty {
|
|
692
784
|
for activity in activities {
|
|
693
785
|
var activityStartDate = ""
|
|
694
786
|
var activityEndDate = ""
|
|
695
787
|
if let start = activity.startDate as Date? {
|
|
696
|
-
activityStartDate = self._dateFormatter.string(from:
|
|
788
|
+
activityStartDate = self._dateFormatter.string(from: start)
|
|
697
789
|
}
|
|
698
790
|
if let end = activity.endDate as Date? {
|
|
699
|
-
activityEndDate = self._dateFormatter.string(from:
|
|
791
|
+
activityEndDate = self._dateFormatter.string(from: end)
|
|
700
792
|
}
|
|
701
793
|
let activityDict: [String: Any] = [
|
|
702
794
|
"startDate": activityStartDate,
|
|
@@ -709,26 +801,11 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
709
801
|
}
|
|
710
802
|
}
|
|
711
803
|
dict["activities"] = activitiesArray
|
|
712
|
-
|
|
804
|
+
|
|
713
805
|
if #available(iOS 11, *) {
|
|
714
806
|
dict.setValue(serializeQuantity(unit: HKUnit.count(), quantity: workout.totalFlightsClimbed), forKey: "totalFlightsClimbed")
|
|
715
807
|
}
|
|
716
|
-
|
|
717
|
-
#if canImport(WorkoutKit)
|
|
718
|
-
if #available(iOS 17.0, *) {
|
|
719
|
-
Task {
|
|
720
|
-
do {
|
|
721
|
-
let workoutplan = try await workout.workoutPlan
|
|
722
|
-
if let workoutplanId = workoutplan?.id {
|
|
723
|
-
dict["workoutPlanId"] = workoutplanId.uuidString
|
|
724
|
-
}
|
|
725
|
-
} catch {
|
|
726
|
-
// handle error
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
#endif
|
|
731
|
-
|
|
808
|
+
|
|
732
809
|
arr.add(dict)
|
|
733
810
|
}
|
|
734
811
|
}
|
|
@@ -1072,18 +1149,14 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1072
1149
|
|
|
1073
1150
|
let samples = try! await withCheckedThrowingContinuation {
|
|
1074
1151
|
(continuation: CheckedContinuation<[HKSample], Error>) in
|
|
1075
|
-
|
|
1076
|
-
predicate: workoutPredicate,
|
|
1077
|
-
anchor: nil,
|
|
1078
|
-
limit: 1) {
|
|
1079
|
-
(_, samples, _, _, error) in
|
|
1152
|
+
let query = HKSampleQuery(sampleType: HKObjectType.workoutType(), predicate: workoutPredicate, limit: 1, sortDescriptors: nil) { (_, results, error) in
|
|
1080
1153
|
|
|
1081
1154
|
if let hasError = error {
|
|
1082
1155
|
continuation.resume(throwing: hasError)
|
|
1083
1156
|
return
|
|
1084
1157
|
}
|
|
1085
1158
|
|
|
1086
|
-
guard let samples =
|
|
1159
|
+
guard let samples = results else {
|
|
1087
1160
|
fatalError("Should not fail")
|
|
1088
1161
|
}
|
|
1089
1162
|
|
|
@@ -1184,6 +1257,63 @@ class ReactNativeHealthkit: RCTEventEmitter {
|
|
|
1184
1257
|
return allRoutes
|
|
1185
1258
|
}
|
|
1186
1259
|
|
|
1260
|
+
@available(iOS 17.0.0, *)
|
|
1261
|
+
func getWorkoutPlan(workout: HKWorkout) async -> [String: Any]? {
|
|
1262
|
+
#if canImport(WorkoutKit)
|
|
1263
|
+
do {
|
|
1264
|
+
let workoutPlan = try await workout.workoutPlan
|
|
1265
|
+
|
|
1266
|
+
var dict = [String: Any]()
|
|
1267
|
+
if (workoutPlan?.id) != nil {
|
|
1268
|
+
dict["id"] = workoutPlan?.id.uuidString
|
|
1269
|
+
|
|
1270
|
+
}
|
|
1271
|
+
if (workoutPlan?.workout.activity) != nil {
|
|
1272
|
+
dict["activityType"] = workoutPlan?.workout.activity.rawValue
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
if dict.isEmpty {
|
|
1276
|
+
return nil
|
|
1277
|
+
}
|
|
1278
|
+
return dict
|
|
1279
|
+
} catch {
|
|
1280
|
+
return nil
|
|
1281
|
+
}
|
|
1282
|
+
#else
|
|
1283
|
+
return nil
|
|
1284
|
+
#endif
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1287
|
+
@objc(getWorkoutPlanById:resolve:reject:)
|
|
1288
|
+
func getWorkoutPlanById(workoutUUID: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1289
|
+
if #available(iOS 17.0, *) {
|
|
1290
|
+
#if canImport(WorkoutKit)
|
|
1291
|
+
guard let store = _store else {
|
|
1292
|
+
return reject(INIT_ERROR, INIT_ERROR_MESSAGE, nil)
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
Task {
|
|
1296
|
+
if let uuid = UUID(uuidString: workoutUUID) {
|
|
1297
|
+
let workout = await self.getWorkoutByID(store: store, workoutUUID: uuid)
|
|
1298
|
+
if let workout {
|
|
1299
|
+
let workoutPlan = await self.getWorkoutPlan(workout: workout)
|
|
1300
|
+
|
|
1301
|
+
return resolve(workoutPlan)
|
|
1302
|
+
} else {
|
|
1303
|
+
return reject(GENERIC_ERROR, "No workout found", nil)
|
|
1304
|
+
}
|
|
1305
|
+
} else {
|
|
1306
|
+
return reject(GENERIC_ERROR, "Invalid UUID", nil)
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
#else
|
|
1310
|
+
return resolve(nil)
|
|
1311
|
+
#endif
|
|
1312
|
+
} else {
|
|
1313
|
+
return resolve(nil)
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1187
1317
|
func serializeLocation(location: CLLocation, previousLocation: CLLocation?) -> [String: Any] {
|
|
1188
1318
|
var distance: CLLocationDistance?
|
|
1189
1319
|
if let previousLocation = previousLocation {
|
|
@@ -22,6 +22,7 @@ var _getMostRecentWorkout = _interopRequireDefault(require("./utils/getMostRecen
|
|
|
22
22
|
var _getPreferredUnit = _interopRequireDefault(require("./utils/getPreferredUnit"));
|
|
23
23
|
var _getPreferredUnits = _interopRequireDefault(require("./utils/getPreferredUnits"));
|
|
24
24
|
var _getRequestStatusForAuthorization = _interopRequireDefault(require("./utils/getRequestStatusForAuthorization"));
|
|
25
|
+
var _getWorkoutPlanById = _interopRequireDefault(require("./utils/getWorkoutPlanById"));
|
|
25
26
|
var _queryCategorySamples = _interopRequireDefault(require("./utils/queryCategorySamples"));
|
|
26
27
|
var _queryCategorySamplesWithAnchor = _interopRequireDefault(require("./utils/queryCategorySamplesWithAnchor"));
|
|
27
28
|
var _queryCorrelationSamples = _interopRequireDefault(require("./utils/queryCorrelationSamples"));
|
|
@@ -36,6 +37,7 @@ var _requestAuthorization = _interopRequireDefault(require("./utils/requestAutho
|
|
|
36
37
|
var _saveCategorySample = _interopRequireDefault(require("./utils/saveCategorySample"));
|
|
37
38
|
var _saveCorrelationSample = _interopRequireDefault(require("./utils/saveCorrelationSample"));
|
|
38
39
|
var _saveQuantitySample = _interopRequireDefault(require("./utils/saveQuantitySample"));
|
|
40
|
+
var _saveWorkoutRoute = _interopRequireDefault(require("./utils/saveWorkoutRoute"));
|
|
39
41
|
var _saveWorkoutSample = _interopRequireDefault(require("./utils/saveWorkoutSample"));
|
|
40
42
|
var _subscribeToChanges = _interopRequireDefault(require("./utils/subscribeToChanges"));
|
|
41
43
|
var _types = require("./types");
|
|
@@ -152,6 +154,7 @@ var _default = {
|
|
|
152
154
|
* @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}
|
|
153
155
|
*/
|
|
154
156
|
getWorkoutRoutes,
|
|
157
|
+
getWorkoutPlanById: _getWorkoutPlanById.default,
|
|
155
158
|
getPreferredUnit: _getPreferredUnit.default,
|
|
156
159
|
getPreferredUnits: _getPreferredUnits.default,
|
|
157
160
|
getRequestStatusForAuthorization: _getRequestStatusForAuthorization.default,
|
|
@@ -179,6 +182,7 @@ var _default = {
|
|
|
179
182
|
saveCorrelationSample: _saveCorrelationSample.default,
|
|
180
183
|
saveQuantitySample: _saveQuantitySample.default,
|
|
181
184
|
saveWorkoutSample: _saveWorkoutSample.default,
|
|
185
|
+
saveWorkoutRoute: _saveWorkoutRoute.default,
|
|
182
186
|
// subscriptions
|
|
183
187
|
subscribeToChanges: _subscribeToChanges.default,
|
|
184
188
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_useHealthkitAuthorization","_interopRequireDefault","_useIsHealthDataAvailable","_useMostRecentCategorySample","_useMostRecentQuantitySample","_useMostRecentWorkout","_useSubscribeToChanges","_nativeTypes","_interopRequireWildcard","_deleteQuantitySample","_deleteSamples","_getDateOfBirth","_getMostRecentCategorySample","_getMostRecentQuantitySample","_getMostRecentWorkout","_getPreferredUnit","_getPreferredUnits","_getRequestStatusForAuthorization","_queryCategorySamples","_queryCategorySamplesWithAnchor","_queryCorrelationSamples","_queryHeartbeatSeriesSamples","_queryHeartbeatSeriesSamplesWithAnchor","_queryQuantitySamples","_queryQuantitySamplesWithAnchor","_querySources","_queryStatisticsForQuantity","_queryWorkouts","_requestAuthorization","_saveCategorySample","_saveCorrelationSample","_saveQuantitySample","_saveWorkoutSample","_subscribeToChanges","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","currentMajorVersionIOS","Platform","OS","parseInt","Version","allQuantityTypesList","values","HKQuantityTypeIdentifier","availableQuantityTypes","majorVersionIOS","arguments","length","undefined","filter","type","cyclingCadence","cyclingFunctionalThresholdPower","cyclingPower","cyclingSpeed","physicalEffort","timeInDaylight","includes","authorizationStatusFor","Native","bind","isHealthDataAvailable","canAccessProtectedData","disableBackgroundDelivery","disableAllBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","_default","isProtectedDataAvailable","getDateOfBirth","getMostRecentQuantitySample","getMostRecentCategorySample","getMostRecentWorkout","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","queryCategorySamples","queryCategorySamplesWithAnchor","queryCorrelationSamples","queryHeartbeatSeriesSamples","queryHeartbeatSeriesSamplesWithAnchor","queryQuantitySamples","queryQuantitySamplesWithAnchor","queryStatisticsForQuantity","queryWorkouts","querySources","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useIsHealthDataAvailable","useHealthkitAuthorization"],"sources":["index.ios.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport useHealthkitAuthorization from './hooks/useHealthkitAuthorization'\nimport useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable'\nimport useMostRecentCategorySample from './hooks/useMostRecentCategorySample'\nimport useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample'\nimport useMostRecentWorkout from './hooks/useMostRecentWorkout'\nimport useSubscribeToChanges from './hooks/useSubscribeToChanges'\nimport Native, { HKQuantityTypeIdentifier } from './native-types'\nimport deleteQuantitySample from './utils/deleteQuantitySample'\nimport deleteSamples from './utils/deleteSamples'\nimport getDateOfBirth from './utils/getDateOfBirth'\nimport getMostRecentCategorySample from './utils/getMostRecentCategorySample'\nimport getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'\nimport getMostRecentWorkout from './utils/getMostRecentWorkout'\nimport getPreferredUnit from './utils/getPreferredUnit'\nimport getPreferredUnits from './utils/getPreferredUnits'\nimport getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'\nimport queryCategorySamples from './utils/queryCategorySamples'\nimport queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'\nimport queryCorrelationSamples from './utils/queryCorrelationSamples'\nimport queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples'\nimport queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor'\nimport queryQuantitySamples from './utils/queryQuantitySamples'\nimport queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'\nimport querySources from './utils/querySources'\nimport queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'\nimport queryWorkouts from './utils/queryWorkouts'\nimport requestAuthorization from './utils/requestAuthorization'\nimport saveCategorySample from './utils/saveCategorySample'\nimport saveCorrelationSample from './utils/saveCorrelationSample'\nimport saveQuantitySample from './utils/saveQuantitySample'\nimport saveWorkoutSample from './utils/saveWorkoutSample'\nimport subscribeToChanges from './utils/subscribeToChanges'\n\nconst currentMajorVersionIOS = Platform.OS === 'ios' ? parseInt(Platform.Version, 10) : 0\n\nconst allQuantityTypesList = [...Object.values(HKQuantityTypeIdentifier)]\n\nconst availableQuantityTypes = (majorVersionIOS = currentMajorVersionIOS) => {\n if (majorVersionIOS >= 17) {\n return allQuantityTypesList\n }\n\n // remove types that are not available before iOS 17\n return allQuantityTypesList.filter((type) => ![\n HKQuantityTypeIdentifier.cyclingCadence,\n HKQuantityTypeIdentifier.cyclingFunctionalThresholdPower,\n HKQuantityTypeIdentifier.cyclingPower,\n HKQuantityTypeIdentifier.cyclingSpeed,\n HKQuantityTypeIdentifier.physicalEffort,\n HKQuantityTypeIdentifier.timeInDaylight,\n ].includes(type))\n}\n\nconst authorizationStatusFor = Native.authorizationStatusFor.bind(Native)\nconst isHealthDataAvailable = Native.isHealthDataAvailable.bind(Native)\n// Todo [>8]: Rename to align with Apple function name (isProtectedDataAvailable)\nconst canAccessProtectedData = Native.canAccessProtectedData.bind(Native)\nconst disableBackgroundDelivery = Native.disableBackgroundDelivery.bind(Native)\nconst disableAllBackgroundDelivery = Native.disableAllBackgroundDelivery.bind(Native)\nconst enableBackgroundDelivery = Native.enableBackgroundDelivery.bind(Native)\nconst getBiologicalSex = Native.getBiologicalSex.bind(Native)\nconst getFitzpatrickSkinType = Native.getFitzpatrickSkinType.bind(Native)\nconst getWheelchairUse = Native.getWheelchairUse.bind(Native)\nconst getBloodType = Native.getBloodType.bind(Native)\nconst getWorkoutRoutes = Native.getWorkoutRoutes.bind(Native)\n\n/**\n * @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}\n */\nexport default {\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }\n */\n authorizationStatusFor,\n\n /**\n *\n * @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)\n */\n availableQuantityTypes,\n\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}\n * @returns {boolean} true if HealthKit is available; otherwise, false.\n */\n isHealthDataAvailable,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n isProtectedDataAvailable: canAccessProtectedData,\n\n // Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n canAccessProtectedData,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}\n */\n disableAllBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}\n */\n disableBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}\n */\n enableBackgroundDelivery,\n\n // simple convenience getters\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}\n */\n getBiologicalSex,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}\n */\n getFitzpatrickSkinType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}\n */\n getWheelchairUse,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}\n */\n getBloodType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}\n */\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}\n */\n getWorkoutRoutes,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n // query methods\n queryCategorySamples,\n queryCategorySamplesWithAnchor,\n queryCorrelationSamples,\n queryHeartbeatSeriesSamples,\n queryHeartbeatSeriesSamplesWithAnchor,\n queryQuantitySamples,\n queryQuantitySamplesWithAnchor,\n queryStatisticsForQuantity,\n queryWorkouts,\n querySources,\n\n requestAuthorization,\n\n // delete methods\n deleteQuantitySample,\n deleteSamples,\n\n // save methods\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}\n */\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n\n // subscriptions\n subscribeToChanges,\n\n /**\n * @returns the most recent sample for the given category type.\n */\n useMostRecentCategorySample,\n /**\n * @returns the most recent sample for the given quantity type.\n */\n useMostRecentQuantitySample,\n /**\n * @returns the most recent workout sample.\n */\n useMostRecentWorkout,\n useSubscribeToChanges,\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}\n * @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.\n */\n useIsHealthDataAvailable,\n /**\n * @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}\n */\n useHealthkitAuthorization,\n}\n\nexport * from './types'\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,0BAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,yBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,4BAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,4BAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,qBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,sBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,YAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,cAAA,GAAAT,sBAAA,CAAAF,OAAA;AACA,IAAAY,eAAA,GAAAV,sBAAA,CAAAF,OAAA;AACA,IAAAa,4BAAA,GAAAX,sBAAA,CAAAF,OAAA;AACA,IAAAc,4BAAA,GAAAZ,sBAAA,CAAAF,OAAA;AACA,IAAAe,qBAAA,GAAAb,sBAAA,CAAAF,OAAA;AACA,IAAAgB,iBAAA,GAAAd,sBAAA,CAAAF,OAAA;AACA,IAAAiB,kBAAA,GAAAf,sBAAA,CAAAF,OAAA;AACA,IAAAkB,iCAAA,GAAAhB,sBAAA,CAAAF,OAAA;AACA,IAAAmB,qBAAA,GAAAjB,sBAAA,CAAAF,OAAA;AACA,IAAAoB,+BAAA,GAAAlB,sBAAA,CAAAF,OAAA;AACA,IAAAqB,wBAAA,GAAAnB,sBAAA,CAAAF,OAAA;AACA,IAA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C9BC,0BAA0B,EAA1BA,mCAA0B;EAC1BC,aAAa,EAAbA,sBAAa;EACbC,YAAY,EAAZA,qBAAY;EAEZC,oBAAoB,EAApBA,6BAAoB;EAEpB;EACAC,oBAAoB,EAApBA,6BAAoB;EACpBC,aAAa,EAAbA,sBAAa;EAEb;EACA;AACF;AACA;AACA;EACEC,kBAAkB,EAAlBA,2BAAkB;EAClBC,qBAAqB,EAArBA,8BAAqB;EACrBC,kBAAkB,EAAlBA,2BAAkB;EAClBC,iBAAiB,EAAjBA,0BAAiB;EAEjB;EACAC,kBAAkB,EAAlBA,2BAAkB;EAElB;AACF;AACA;EACEC,2BAA2B,EAA3BA,oCAA2B;EAC3B;AACF;AACA;EACEC,2BAA2B,EAA3BA,oCAA2B;EAC3B;AACF;AACA;EACEC,oBAAoB,EAApBA,6BAAoB;EACpBC,qBAAqB,EAArBA,8BAAqB;EACrB;AACF;AACA;AACA;AACA;EACEC,wBAAwB,EAAxBA,iCAAwB;EACxB;AACF;AACA;AACA;AACA;EACEC,yBAAyB,EAAzBA;AACF,CAAC;AAAAtF,OAAA,CAAAW,OAAA,GAAA2C,QAAA"}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_useHealthkitAuthorization","_interopRequireDefault","_useIsHealthDataAvailable","_useMostRecentCategorySample","_useMostRecentQuantitySample","_useMostRecentWorkout","_useSubscribeToChanges","_nativeTypes","_interopRequireWildcard","_deleteQuantitySample","_deleteSamples","_getDateOfBirth","_getMostRecentCategorySample","_getMostRecentQuantitySample","_getMostRecentWorkout","_getPreferredUnit","_getPreferredUnits","_getRequestStatusForAuthorization","_getWorkoutPlanById","_queryCategorySamples","_queryCategorySamplesWithAnchor","_queryCorrelationSamples","_queryHeartbeatSeriesSamples","_queryHeartbeatSeriesSamplesWithAnchor","_queryQuantitySamples","_queryQuantitySamplesWithAnchor","_querySources","_queryStatisticsForQuantity","_queryWorkouts","_requestAuthorization","_saveCategorySample","_saveCorrelationSample","_saveQuantitySample","_saveWorkoutRoute","_saveWorkoutSample","_subscribeToChanges","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","newObj","hasPropertyDescriptor","getOwnPropertyDescriptor","desc","set","currentMajorVersionIOS","Platform","OS","parseInt","Version","allQuantityTypesList","values","HKQuantityTypeIdentifier","availableQuantityTypes","majorVersionIOS","arguments","length","undefined","filter","type","cyclingCadence","cyclingFunctionalThresholdPower","cyclingPower","cyclingSpeed","physicalEffort","timeInDaylight","includes","authorizationStatusFor","Native","bind","isHealthDataAvailable","canAccessProtectedData","disableBackgroundDelivery","disableAllBackgroundDelivery","enableBackgroundDelivery","getBiologicalSex","getFitzpatrickSkinType","getWheelchairUse","getBloodType","getWorkoutRoutes","_default","isProtectedDataAvailable","getDateOfBirth","getMostRecentQuantitySample","getMostRecentCategorySample","getMostRecentWorkout","getWorkoutPlanById","getPreferredUnit","getPreferredUnits","getRequestStatusForAuthorization","queryCategorySamples","queryCategorySamplesWithAnchor","queryCorrelationSamples","queryHeartbeatSeriesSamples","queryHeartbeatSeriesSamplesWithAnchor","queryQuantitySamples","queryQuantitySamplesWithAnchor","queryStatisticsForQuantity","queryWorkouts","querySources","requestAuthorization","deleteQuantitySample","deleteSamples","saveCategorySample","saveCorrelationSample","saveQuantitySample","saveWorkoutSample","saveWorkoutRoute","subscribeToChanges","useMostRecentCategorySample","useMostRecentQuantitySample","useMostRecentWorkout","useSubscribeToChanges","useIsHealthDataAvailable","useHealthkitAuthorization"],"sources":["index.ios.tsx"],"sourcesContent":["import { Platform } from 'react-native'\n\nimport useHealthkitAuthorization from './hooks/useHealthkitAuthorization'\nimport useIsHealthDataAvailable from './hooks/useIsHealthDataAvailable'\nimport useMostRecentCategorySample from './hooks/useMostRecentCategorySample'\nimport useMostRecentQuantitySample from './hooks/useMostRecentQuantitySample'\nimport useMostRecentWorkout from './hooks/useMostRecentWorkout'\nimport useSubscribeToChanges from './hooks/useSubscribeToChanges'\nimport Native, { HKQuantityTypeIdentifier } from './native-types'\nimport deleteQuantitySample from './utils/deleteQuantitySample'\nimport deleteSamples from './utils/deleteSamples'\nimport getDateOfBirth from './utils/getDateOfBirth'\nimport getMostRecentCategorySample from './utils/getMostRecentCategorySample'\nimport getMostRecentQuantitySample from './utils/getMostRecentQuantitySample'\nimport getMostRecentWorkout from './utils/getMostRecentWorkout'\nimport getPreferredUnit from './utils/getPreferredUnit'\nimport getPreferredUnits from './utils/getPreferredUnits'\nimport getRequestStatusForAuthorization from './utils/getRequestStatusForAuthorization'\nimport getWorkoutPlanById from './utils/getWorkoutPlanById'\nimport queryCategorySamples from './utils/queryCategorySamples'\nimport queryCategorySamplesWithAnchor from './utils/queryCategorySamplesWithAnchor'\nimport queryCorrelationSamples from './utils/queryCorrelationSamples'\nimport queryHeartbeatSeriesSamples from './utils/queryHeartbeatSeriesSamples'\nimport queryHeartbeatSeriesSamplesWithAnchor from './utils/queryHeartbeatSeriesSamplesWithAnchor'\nimport queryQuantitySamples from './utils/queryQuantitySamples'\nimport queryQuantitySamplesWithAnchor from './utils/queryQuantitySamplesWithAnchor'\nimport querySources from './utils/querySources'\nimport queryStatisticsForQuantity from './utils/queryStatisticsForQuantity'\nimport queryWorkouts from './utils/queryWorkouts'\nimport requestAuthorization from './utils/requestAuthorization'\nimport saveCategorySample from './utils/saveCategorySample'\nimport saveCorrelationSample from './utils/saveCorrelationSample'\nimport saveQuantitySample from './utils/saveQuantitySample'\nimport saveWorkoutRoute from './utils/saveWorkoutRoute'\nimport saveWorkoutSample from './utils/saveWorkoutSample'\nimport subscribeToChanges from './utils/subscribeToChanges'\n\nconst currentMajorVersionIOS = Platform.OS === 'ios' ? parseInt(Platform.Version, 10) : 0\n\nconst allQuantityTypesList = [...Object.values(HKQuantityTypeIdentifier)]\n\nconst availableQuantityTypes = (majorVersionIOS = currentMajorVersionIOS) => {\n if (majorVersionIOS >= 17) {\n return allQuantityTypesList\n }\n\n // remove types that are not available before iOS 17\n return allQuantityTypesList.filter((type) => ![\n HKQuantityTypeIdentifier.cyclingCadence,\n HKQuantityTypeIdentifier.cyclingFunctionalThresholdPower,\n HKQuantityTypeIdentifier.cyclingPower,\n HKQuantityTypeIdentifier.cyclingSpeed,\n HKQuantityTypeIdentifier.physicalEffort,\n HKQuantityTypeIdentifier.timeInDaylight,\n ].includes(type))\n}\n\nconst authorizationStatusFor = Native.authorizationStatusFor.bind(Native)\nconst isHealthDataAvailable = Native.isHealthDataAvailable.bind(Native)\n// Todo [>8]: Rename to align with Apple function name (isProtectedDataAvailable)\nconst canAccessProtectedData = Native.canAccessProtectedData.bind(Native)\nconst disableBackgroundDelivery = Native.disableBackgroundDelivery.bind(Native)\nconst disableAllBackgroundDelivery = Native.disableAllBackgroundDelivery.bind(Native)\nconst enableBackgroundDelivery = Native.enableBackgroundDelivery.bind(Native)\nconst getBiologicalSex = Native.getBiologicalSex.bind(Native)\nconst getFitzpatrickSkinType = Native.getFitzpatrickSkinType.bind(Native)\nconst getWheelchairUse = Native.getWheelchairUse.bind(Native)\nconst getBloodType = Native.getBloodType.bind(Native)\nconst getWorkoutRoutes = Native.getWorkoutRoutes.bind(Native)\n\n/**\n * @see {@link https://developer.apple.com/documentation/healthkit/about_the_healthkit_framework About the HealthKit Framework (Apple Docs)}\n */\nexport default {\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614154-authorizationstatus authorizationStatus(for:) (Apple Docs) }\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Authorizing access to health data (Apple Docs) }\n */\n authorizationStatusFor,\n\n /**\n *\n * @returns All available quantity types for the current iOS version (currently excluding types that are not available before iOS 17)\n */\n availableQuantityTypes,\n\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable isHealthDataAvailable() (Apple Docs)}\n * @returns {boolean} true if HealthKit is available; otherwise, false.\n */\n isHealthDataAvailable,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n isProtectedDataAvailable: canAccessProtectedData,\n\n // Todo [>8]: Remove to align with Apple function name (isProtectedDataAvailable)\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614181-isprotecteddataavailable isProtectedDataAvailable() (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/protecting_user_privacy#3705074 Protecting User Privacy - Access encrypted data (Apple Docs)}\n * @deprecated Use {@link isProtectedDataAvailable} instead. Will be removed in next major version.\n * @returns {boolean} A Boolean value that indicates whether content protection is active.\n */\n canAccessProtectedData,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614158-disableallbackgrounddelivery disableAllBackgroundDelivery(completion:) (Apple Docs)}\n */\n disableAllBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614177-disablebackgrounddelivery disableBackgroundDelivery(for:withCompletion:) (Apple Docs)}\n */\n disableBackgroundDelivery,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614175-enablebackgrounddelivery enableBackgroundDelivery(for:frequency:withCompletion:) (Apple Docs)}\n */\n enableBackgroundDelivery,\n\n // simple convenience getters\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614171-biologicalsex biologicalSex() (Apple Docs)}\n */\n getBiologicalSex,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614161-fitzpatrickskintype fitzpatrickSkinType() (Apple Docs)}\n */\n getFitzpatrickSkinType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648356-wheelchairuse wheelchairUse() (Apple Docs)}\n */\n getWheelchairUse,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614164-bloodtype bloodType() (Apple Docs)}\n */\n getBloodType,\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1648357-dateofbirthcomponents dateOfBirthComponents() (Apple Docs)}\n */\n getDateOfBirth,\n\n getMostRecentQuantitySample,\n getMostRecentCategorySample,\n getMostRecentWorkout,\n\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/workouts_and_activity_rings/reading_route_data Reading route data (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/hkworkoutroutequery HKWorkoutRouteQuery (Apple Docs)}\n */\n getWorkoutRoutes,\n getWorkoutPlanById,\n\n getPreferredUnit,\n getPreferredUnits,\n getRequestStatusForAuthorization,\n\n // query methods\n queryCategorySamples,\n queryCategorySamplesWithAnchor,\n queryCorrelationSamples,\n queryHeartbeatSeriesSamples,\n queryHeartbeatSeriesSamplesWithAnchor,\n queryQuantitySamples,\n queryQuantitySamplesWithAnchor,\n queryStatisticsForQuantity,\n queryWorkouts,\n querySources,\n\n requestAuthorization,\n\n // delete methods\n deleteQuantitySample,\n deleteSamples,\n\n // save methods\n /**\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614168-savecategorysample save(_:withCompletion:) (Apple Docs)}\n * @see {@link https://developer.apple.com/documentation/healthkit/saving_data_to_healthkit Saving data to HealthKit (Apple Docs)}\n */\n saveCategorySample,\n saveCorrelationSample,\n saveQuantitySample,\n saveWorkoutSample,\n saveWorkoutRoute,\n\n // subscriptions\n subscribeToChanges,\n\n /**\n * @returns the most recent sample for the given category type.\n */\n useMostRecentCategorySample,\n /**\n * @returns the most recent sample for the given quantity type.\n */\n useMostRecentQuantitySample,\n /**\n * @returns the most recent workout sample.\n */\n useMostRecentWorkout,\n useSubscribeToChanges,\n /**\n * @description By default, HealthKit data is available on iOS and watchOS. HealthKit data is also available on iPadOS 17 or later. However, devices running in an enterprise environment may restrict access to HealthKit data.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614180-ishealthdataavailable Apple Docs}\n * @returns {boolean | null} true if HealthKit is available; otherwise, false. null while initializing.\n */\n useIsHealthDataAvailable,\n /**\n * @description Hook to retrieve the current authorization status for the given types, and request authorization if needed.\n * @see {@link https://developer.apple.com/documentation/healthkit/hkhealthstore/1614152-requestauthorization Apple Docs - requestAuthorization}\n * @see {@link https://developer.apple.com/documentation/healthkit/authorizing_access_to_health_data Apple Docs - Authorizing access to health data}\n */\n useHealthkitAuthorization,\n}\n\nexport * from './types'\n"],"mappings":";;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,0BAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,yBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,4BAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,4BAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,qBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,sBAAA,GAAAL,sBAAA,CAAAF,OAAA;AACA,IAAAQ,YAAA,GAAAC,uBAAA,CAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAR,sBAAA,CAAAF,OAAA;AACA,IAAAW,cAAA,GAAAT,sBAAA,CAAAF,OAAA;AACA,IAAAY,eAAA,GAAAV,sBAAA,CAAAF,OAAA;AACA,IAAAa,4BAAA,GAAAX,sBAAA,CAAAF,OAAA;AACA,IAAAc,4BAAA,GAAAZ,sBAAA,CAAAF,OAAA;AACA,IAAAe,qBAAA,GAAAb,sBAAA,CAAAF,OAAA;AACA,IAAAgB,iBAAA,GAAAd,sBAAA,CAAAF,OAAA;AACA,IAAAiB,kBAAA,GAAAf,sBAAA,CAAAF,OAAA;AACA,IAAAkB,iCAAA,GAA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,yBAAgB;EAChBC,iBAAiB,EAAjBA,0BAAiB;EACjBC,gCAAgC,EAAhCA,yCAAgC;EAEhC;EACAC,oBAAoB,EAApBA,6BAAoB;EACpBC,8BAA8B,EAA9BA,uCAA8B;EAC9BC,uBAAuB,EAAvBA,gCAAuB;EACvBC,2BAA2B,EAA3BA,oCAA2B;EAC3BC,qCAAqC,EAArCA,8CAAqC;EACrCC,oBAAoB,EAApBA,6BAAoB;EACpBC,8BAA8B,EAA9BA,uCAA8B;EAC9BC,0BAA0B,EAA1BA,mCAA0B;EAC1BC,aAAa,EAAbA,sBAAa;EACbC,YAAY,EAAZA,qBAAY;EAEZC,oBAAoB,EAApBA,6BAAoB;EAEpB;EACAC,oBAAoB,EAApBA,6BAAoB;EACpBC,aAAa,EAAbA,sBAAa;EAEb;EACA;AACF;AACA;AACA;EACEC,kBAAkB,EAAlBA,2BAAkB;EAClBC,qBAAqB,EAArBA,8BAAqB;EACrBC,kBAAkB,EAAlBA,2BAAkB;EAClBC,iBAAiB,EAAjBA,0BAAiB;EACjBC,gBAAgB,EAAhBA,yBAAgB;EAEhB;EACAC,kBAAkB,EAAlBA,2BAAkB;EAElB;AACF;AACA;EACEC,2BAA2B,EAA3BA,oCAA2B;EAC3B;AACF;AACA;EACEC,2BAA2B,EAA3BA,oCAA2B;EAC3B;AACF;AACA;EACEC,oBAAoB,EAApBA,6BAAoB;EACpBC,qBAAqB,EAArBA,8BAAqB;EACrB;AACF;AACA;AACA;AACA;EACEC,wBAAwB,EAAxBA,iCAAwB;EACxB;AACF;AACA;AACA;AACA;EACEC,yBAAyB,EAAzBA;AACF,CAAC;AAAAxF,OAAA,CAAAW,OAAA,GAAA2C,QAAA"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -83,10 +83,12 @@ const Healthkit = {
|
|
|
83
83
|
requestAuthorization: UnavailableFn(Promise.resolve(false)),
|
|
84
84
|
deleteQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
85
85
|
deleteSamples: UnavailableFn(Promise.resolve(false)),
|
|
86
|
+
getWorkoutPlanById: UnavailableFn(Promise.resolve(null)),
|
|
86
87
|
saveCategorySample: UnavailableFn(Promise.resolve(false)),
|
|
87
88
|
saveCorrelationSample: UnavailableFn(Promise.resolve(false)),
|
|
88
89
|
saveQuantitySample: UnavailableFn(Promise.resolve(false)),
|
|
89
|
-
saveWorkoutSample: UnavailableFn(Promise.resolve(
|
|
90
|
+
saveWorkoutSample: UnavailableFn(Promise.resolve(null)),
|
|
91
|
+
saveWorkoutRoute: UnavailableFn(Promise.resolve(false)),
|
|
90
92
|
subscribeToChanges: UnavailableFn(Promise.resolve(async () => Promise.resolve(false))),
|
|
91
93
|
useMostRecentCategorySample: UnavailableFn(null),
|
|
92
94
|
useMostRecentQuantitySample: UnavailableFn(null),
|