Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add HK RunningSpeed to permissions #249

Merged
merged 4 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add HK RunningSpeed to permissions
  • Loading branch information
walterholohan committed Sep 20, 2022
commit 711d2c73a4cacca864c7cbc6ca5c774c43b6b678
18 changes: 17 additions & 1 deletion RCTAppleHealthKit/RCTAppleHealthKit+TypesAndPermissions.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ - (nullable HKObjectType *)getReadPermFromText:(nonnull NSString*)key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
} else if ([@"DistanceWalkingRunning" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
} else if ([@"RunningSpeed" isEqualToString: key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningSpeed];
} else {
return nil;
}
} else if ([@"DistanceCycling" isEqualToString: key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling];
} else if ([@"DistanceSwimming" isEqualToString: key]) {
Expand Down Expand Up @@ -260,6 +266,12 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierStepCount];
} else if ([@"DistanceWalkingRunning" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceWalkingRunning];
} else if ([@"RunningSpeed" isEqualToString:key]) {
if (@available(iOS 16.0, *)) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierRunningSpeed];
} else {
return nil;
}
} else if ([@"DistanceCycling" isEqualToString:key]) {
return [HKObjectType quantityTypeForIdentifier:HKQuantityTypeIdentifierDistanceCycling];
} else if ([@"DistanceSwimming" isEqualToString:key]) {
Expand Down Expand Up @@ -370,7 +382,11 @@ - (nullable HKObjectType *)getWritePermFromText:(nonnull NSString*) key {

// Workout Route
if ([@"WorkoutRoute" isEqualToString:key]) {
return [HKSeriesType workoutRouteType];
if (@available(iOS 11.0, *)) {
return [HKSeriesType workoutRouteType];
} else {
return nil;
}
}

// Lab and tests
Expand Down
33 changes: 16 additions & 17 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare module 'react-native-health' {
}

export interface HKErrorResponse {
message?: string;
message?: string
}

export interface AppleHealthKit {
Expand Down Expand Up @@ -465,10 +465,10 @@ declare module 'react-native-health' {
}

export interface HeartbeatSeriesSampleValue extends BaseValue {
heartbeatSeries: ({
heartbeatSeries: {
timeSinceSeriesStart: number
precededByGap: boolean
})[]
}[]
}

export interface HealthUnitOptions {
Expand Down Expand Up @@ -513,15 +513,13 @@ declare module 'react-native-health' {
end: string
}



export interface ElectrocardiogramSampleValue extends BaseValue {
classification: ElectrocardiogramClassification,
averageHeartRate: number,
samplingFrequency: number,
device: string,
algorithmVersion: number,
voltageMeasurements: (number[])[]
classification: ElectrocardiogramClassification
averageHeartRate: number
samplingFrequency: number
device: string
algorithmVersion: number
voltageMeasurements: number[][]
}

export interface HealthValueOptions extends HealthUnitOptions {
Expand Down Expand Up @@ -565,14 +563,14 @@ declare module 'react-native-health' {
LabResultRecord = 'LabResultRecord',
MedicationRecord = 'MedicationRecord',
ProcedureRecord = 'ProcedureRecord',
VitalSignRecord = 'VitalSignRecord'
VitalSignRecord = 'VitalSignRecord',
}

export interface HealthClinicalRecord extends BaseValue {
sourceName: string,
sourceId: string,
displayName: string,
fhirData: any,
sourceName: string
sourceId: string
displayName: string
fhirData: any
}

/* Health Constants */
Expand Down Expand Up @@ -746,7 +744,8 @@ declare module 'react-native-health' {
WalkingHeartRateAverage = 'WalkingHeartRateAverage',
Weight = 'Weight',
Workout = 'Workout',
WorkoutRoute = 'WorkoutRoute'
WorkoutRoute = 'WorkoutRoute',
RunningSpeed = 'RunningSpeed',
}

export enum HealthUnit {
Expand Down
5 changes: 3 additions & 2 deletions src/constants/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
export const Permissions = {
ActiveEnergyBurned: 'ActiveEnergyBurned',
ActivitySummary: "ActivitySummary",
ActivitySummary: 'ActivitySummary',
AllergyRecord: 'AllergyRecord',
AppleExerciseTime: 'AppleExerciseTime',
AppleStandTime: 'AppleStandTime',
Expand Down Expand Up @@ -91,5 +91,6 @@ export const Permissions = {
WalkingHeartRateAverage: 'WalkingHeartRateAverage',
Weight: 'Weight',
Workout: 'Workout',
WorkoutRoute: 'WorkoutRoute'
WorkoutRoute: 'WorkoutRoute',
RunningSpeed: 'RunningSpeed',
}