Skip to content

Commit 711d2c7

Browse files
committed
feat: add HK RunningSpeed to permissions
1 parent bfa18fe commit 711d2c7

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
5959
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
6060
} else if ([@"DistanceWalkingRunning" isEqualToString: key]) {
6161
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
62+
} else if ([@"RunningSpeed" isEqualToString: key]) {
63+
if (@available(iOS 16.0, *)) {
64+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningSpeed];
65+
} else {
66+
return nil;
67+
}
6268
} else if ([@"DistanceCycling" isEqualToString: key]) {
6369
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling];
6470
} else if ([@"DistanceSwimming" isEqualToString: key]) {
@@ -260,6 +266,12 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {
260266
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
261267
} else if ([@"DistanceWalkingRunning" isEqualToString:key]) {
262268
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
269+
} else if ([@"RunningSpeed" isEqualToString:key]) {
270+
if (@available(iOS 16.0, *)) {
271+
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningSpeed];
272+
} else {
273+
return nil;
274+
}
263275
} else if ([@"DistanceCycling" isEqualToString:key]) {
264276
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling];
265277
} else if ([@"DistanceSwimming" isEqualToString:key]) {
@@ -370,7 +382,11 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {
370382

371383
// Workout Route
372384
if ([@"WorkoutRoute" isEqualToString:key]) {
373-
return [HKSeriesType workoutRouteType];
385+
if (@available(iOS 11.0, *)) {
386+
return [HKSeriesType workoutRouteType];
387+
} else {
388+
return nil;
389+
}
374390
}
375391

376392
// Lab and tests

index.d.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare module 'react-native-health' {
1616
}
1717

1818
export interface HKErrorResponse {
19-
message?: string;
19+
message?: string
2020
}
2121

2222
export interface AppleHealthKit {
@@ -465,10 +465,10 @@ declare module 'react-native-health' {
465465
}
466466

467467
export interface HeartbeatSeriesSampleValue extends BaseValue {
468-
heartbeatSeries: ({
468+
heartbeatSeries: {
469469
timeSinceSeriesStart: number
470470
precededByGap: boolean
471-
})[]
471+
}[]
472472
}
473473

474474
export interface HealthUnitOptions {
@@ -513,15 +513,13 @@ declare module 'react-native-health' {
513513
end: string
514514
}
515515

516-
517-
518516
export interface ElectrocardiogramSampleValue extends BaseValue {
519-
classification: ElectrocardiogramClassification,
520-
averageHeartRate: number,
521-
samplingFrequency: number,
522-
device: string,
523-
algorithmVersion: number,
524-
voltageMeasurements: (number[])[]
517+
classification: ElectrocardiogramClassification
518+
averageHeartRate: number
519+
samplingFrequency: number
520+
device: string
521+
algorithmVersion: number
522+
voltageMeasurements: number[][]
525523
}
526524

527525
export interface HealthValueOptions extends HealthUnitOptions {
@@ -565,14 +563,14 @@ declare module 'react-native-health' {
565563
LabResultRecord = 'LabResultRecord',
566564
MedicationRecord = 'MedicationRecord',
567565
ProcedureRecord = 'ProcedureRecord',
568-
VitalSignRecord = 'VitalSignRecord'
566+
VitalSignRecord = 'VitalSignRecord',
569567
}
570568

571569
export interface HealthClinicalRecord extends BaseValue {
572-
sourceName: string,
573-
sourceId: string,
574-
displayName: string,
575-
fhirData: any,
570+
sourceName: string
571+
sourceId: string
572+
displayName: string
573+
fhirData: any
576574
}
577575

578576
/* Health Constants */
@@ -746,7 +744,8 @@ declare module 'react-native-health' {
746744
WalkingHeartRateAverage = 'WalkingHeartRateAverage',
747745
Weight = 'Weight',
748746
Workout = 'Workout',
749-
WorkoutRoute = 'WorkoutRoute'
747+
WorkoutRoute = 'WorkoutRoute',
748+
RunningSpeed = 'RunningSpeed',
750749
}
751750

752751
export enum HealthUnit {

src/constants/Permissions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
export const Permissions = {
77
ActiveEnergyBurned: 'ActiveEnergyBurned',
8-
ActivitySummary: "ActivitySummary",
8+
ActivitySummary: 'ActivitySummary',
99
AllergyRecord: 'AllergyRecord',
1010
AppleExerciseTime: 'AppleExerciseTime',
1111
AppleStandTime: 'AppleStandTime',
@@ -91,5 +91,6 @@ export const Permissions = {
9191
WalkingHeartRateAverage: 'WalkingHeartRateAverage',
9292
Weight: 'Weight',
9393
Workout: 'Workout',
94-
WorkoutRoute: 'WorkoutRoute'
94+
WorkoutRoute: 'WorkoutRoute',
95+
RunningSpeed: 'RunningSpeed',
9596
}

0 commit comments

Comments
 (0)