Skip to content

Commit a82d2d0

Browse files
committed
feat: add 4 running WatchOS9 metrics
1 parent 711d2c7 commit a82d2d0

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m

+48
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,30 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
8181
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleStandTime];
8282
} else if ([@"AppleExerciseTime" isEqualToString: key] && systemVersion >= 9.3) {
8383
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleExerciseTime];
84+
} else if ([@"RunningPower" isEqualToString:key]) {
85+
if (@available(iOS 16.0, *)) {
86+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningPower];
87+
} else {
88+
return nil;
89+
}
90+
} else if ([@"RunningStrideLength" isEqualToString:key]) {
91+
if (@available(iOS 16.0, *)) {
92+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningStrideLength];
93+
} else {
94+
return nil;
95+
}
96+
} else if ([@"RunningVerticalOscillation" isEqualToString:key]) {
97+
if (@available(iOS 16.0, *)) {
98+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningVerticalOscillation];
99+
} else {
100+
return nil;
101+
}
102+
} else if ([@"RunningGroundContactTime" isEqualToString:key]) {
103+
if (@available(iOS 16.0, *)) {
104+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningGroundContactTime];
105+
} else {
106+
return nil;
107+
}
84108
}
85109

86110
// Nutrition Identifiers
@@ -282,6 +306,30 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {
282306
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned];
283307
} else if ([@"FlightsClimbed" isEqualToString:key]) {
284308
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed];
309+
} else if ([@"RunningPower" isEqualToString:key]) {
310+
if (@available(iOS 16.0, *)) {
311+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningPower];
312+
} else {
313+
return nil;
314+
}
315+
} else if ([@"RunningStrideLength" isEqualToString:key]) {
316+
if (@available(iOS 16.0, *)) {
317+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningStrideLength];
318+
} else {
319+
return nil;
320+
}
321+
} else if ([@"RunningVerticalOscillation" isEqualToString:key]) {
322+
if (@available(iOS 16.0, *)) {
323+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningVerticalOscillation];
324+
} else {
325+
return nil;
326+
}
327+
} else if ([@"RunningGroundContactTime" isEqualToString:key]) {
328+
if (@available(iOS 16.0, *)) {
329+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningGroundContactTime];
330+
} else {
331+
return nil;
332+
}
285333
}
286334

287335
// Nutrition Identifiers

index.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,10 @@ declare module 'react-native-health' {
746746
Workout = 'Workout',
747747
WorkoutRoute = 'WorkoutRoute',
748748
RunningSpeed = 'RunningSpeed',
749+
RunningPower = 'RunningPower',
750+
RunningStrideLength = 'RunningStrideLength',
751+
RunningVerticalOscillation = 'RunningVerticalOscillation',
752+
RunningGroundContactTime = 'RunningGroundContactTime',
749753
}
750754

751755
export enum HealthUnit {

src/constants/Permissions.js

+4
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,8 @@ export const Permissions = {
9393
Workout: 'Workout',
9494
WorkoutRoute: 'WorkoutRoute',
9595
RunningSpeed: 'RunningSpeed',
96+
RunningPower: 'RunningPower',
97+
RunningStrideLength: 'RunningStrideLength',
98+
RunningVerticalOscillation: 'RunningVerticalOscillation',
99+
RunningGroundContactTime: 'RunningGroundContactTime',
96100
}

0 commit comments

Comments
 (0)