Skip to content

Commit

Permalink
feat: add 4 running WatchOS9 metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
walterholohan committed Sep 30, 2022
1 parent 711d2c7 commit a82d2d0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
48 changes: 48 additions & 0 deletions RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,30 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleStandTime];
} else if ([@"AppleExerciseTime" isEqualToString: key] && systemVersion >= 9.3) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierAppleExerciseTime];
} else if ([@"RunningPower" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningPower];
} else {
return nil;
}
} else if ([@"RunningStrideLength" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningStrideLength];
} else {
return nil;
}
} else if ([@"RunningVerticalOscillation" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningVerticalOscillation];
} else {
return nil;
}
} else if ([@"RunningGroundContactTime" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningGroundContactTime];
} else {
return nil;
}
}

// Nutrition Identifiers
Expand Down Expand Up @@ -282,6 +306,30 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierActiveEnergyBurned];
} else if ([@"FlightsClimbed" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierFlightsClimbed];
} else if ([@"RunningPower" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningPower];
} else {
return nil;
}
} else if ([@"RunningStrideLength" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningStrideLength];
} else {
return nil;
}
} else if ([@"RunningVerticalOscillation" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningVerticalOscillation];
} else {
return nil;
}
} else if ([@"RunningGroundContactTime" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningGroundContactTime];
} else {
return nil;
}
}

// Nutrition Identifiers
Expand Down
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,10 @@ declare module 'react-native-health' {
Workout = 'Workout',
WorkoutRoute = 'WorkoutRoute',
RunningSpeed = 'RunningSpeed',
RunningPower = 'RunningPower',
RunningStrideLength = 'RunningStrideLength',
RunningVerticalOscillation = 'RunningVerticalOscillation',
RunningGroundContactTime = 'RunningGroundContactTime',
}

export enum HealthUnit {
Expand Down
4 changes: 4 additions & 0 deletions src/constants/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,8 @@ export const Permissions = {
Workout: 'Workout',
WorkoutRoute: 'WorkoutRoute',
RunningSpeed: 'RunningSpeed',
RunningPower: 'RunningPower',
RunningStrideLength: 'RunningStrideLength',
RunningVerticalOscillation: 'RunningVerticalOscillation',
RunningGroundContactTime: 'RunningGroundContactTime',
}

0 comments on commit a82d2d0

Please sign in to comment.