-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ios): add HealthKit.queryAnchoredWorkouts method
- Loading branch information
Showing
5 changed files
with
146 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { NativeModules } from 'react-native'; | ||
|
||
import { HealthKitWorkoutType } from '../../enums'; | ||
import { HealthKitAnchoredWorkoutResult } from '../../types'; | ||
import { isIOS } from '../../utils'; | ||
|
||
/** @internal */ | ||
const { RNHealthTracker } = NativeModules; | ||
|
||
/** | ||
* Query workouts with anchor | ||
* Passing anchor will return all workouts that have been added since that anchor point | ||
* | ||
* @param options.anchor last query anchor point | ||
* @param options.key e.g. `HealthKitWorkoutType.Running`HealthKit | ||
* @param options.limit limits the number of workouts returned from the anchor point to the newest workout | ||
* | ||
* @return Returns an object with the latest anchor point and data array with new workouts | ||
*/ | ||
export const queryAnchoredWorkouts = async (options?: { | ||
anchor?: number; | ||
key?: HealthKitWorkoutType; | ||
limit?: number; | ||
}): Promise<HealthKitAnchoredWorkoutResult> => { | ||
if (isIOS) { | ||
const { anchor = 0, key = 0, limit = 0 } = options || {}; | ||
|
||
return RNHealthTracker.anchoredQueryWorkouts(key, anchor, limit); | ||
} | ||
|
||
throw new Error('queryAnchoredWorkouts is implemented only for iOS platform'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters