1.0.2 • Published 10 months ago

@codoffer/capacitor-healthkit v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Capacitor HealthKit Plugin

:heart: Capacitor plugin to retrieve data from HealthKit :heart:

This is a clone of the @perfood/capacitor-healthkit@next with improvements.

Disclaimer : for now only some of the HK data base, in the future the retrieve base will be bigger !

Getting Started

Prerequisites

  • Add HealthKit to your Xcode project (section signing & capabilities)

alt text

  • ADD Privacy - Health Share Usage Description to your Xcode project
  • ADD Privacy - Health Update Usage Description to your Xcode project

You can simply put this into the info.plist file

	<key>NSHealthShareUsageDescription</key>
	<string>Read Health Data</string>
	<key>NSHealthUpdateUsageDescription</key>
	<string>Read Health Data</string>

Installing

Do

npm i --save @codoffer/capacitor-healthkit

Then

npx cap update

API

requestAuthorization(...)

requestAuthorization(options: RequestAuthorizationOptions) => Promise<void>
ParamType
optionsRequestAuthorizationOptions

isAvailable()

isAvailable() => Promise<void>

getAuthorizationStatus(...)

getAuthorizationStatus(options: GetAuthorizationStatusOptions) => Promise<{ status: AuthorizationStatus; }>
ParamType
optionsGetAuthorizationStatusOptions

Returns: Promise<{ status: AuthorizationStatus; }>


getStatisticsCollection(...)

getStatisticsCollection(options: StatisticsCollectionOptions) => Promise<StatisticsCollectionOutput>
ParamType
optionsStatisticsCollectionOptions

Returns: Promise<StatisticsCollectionOutput>


getBodyMassEntries(...)

getBodyMassEntries(options: BodyMassQueryOptions) => Promise<BodyMassQueryOutput>
ParamType
optionsBodyMassQueryOptions

Returns: Promise<BodyMassQueryOutput>


getWorkouts(...)

getWorkouts(options: WorkoutsQueryOptions) => Promise<WorkoutsQueryOutput>
ParamType
optionsWorkoutsQueryOptions

Returns: Promise<WorkoutsQueryOutput>


Interfaces

RequestAuthorizationOptions

PropType
allstring[]
readstring[]
writestring[]

GetAuthorizationStatusOptions

PropType
sampleNamestring

StatisticsCollectionOutput

PropType
data{ startDate: string; endDate: string; value: number; }[]

StatisticsCollectionOptions

PropType
startDatestring
endDatestring
anchorDatestring
intervalStatisticsCollectionQueryInterval
quantityTypeSampleNameQuantityType

StatisticsCollectionQueryInterval

PropType
unit'second' | 'minute' | 'hour' | 'day' | 'month' | 'year'
valuenumber

BodyMassQueryOutput

PropType
data{ date: string; value: number; unit: string; uuid: string; sourceName: string; sourceBundleId: string; }[]

BodyMassQueryOptions

PropType
startDatestring
endDatestring
limitnumber

WorkoutsQueryOutput

PropType
data{ uuid: string; startDate: string; endDate: string; duration: number; device?: HealthKitDevice; source: string; sourceBundleId: string; workoutActivityType: string; workoutActivityTypeId: number; totalEnergyBurned?: number; totalDistance?: number; totalFlightsClimbed?: number; totalSwimmingStrokeCount?: number; }[]

HealthKitDevice

PropType
namestring
modelstring
manufacturerstring
hardwareVersionstring
softwareVersionstring
firmwareVersionstring
localIdentifierstring
udiDeviceIdentifierstring

WorkoutsQueryOptions

PropType
startDatestring
endDatestring
limitnumber

Type Aliases

AuthorizationStatus

'notDetermined' | 'sharingDenied' | 'sharingAuthorized'

QuantityType

'stepCount' | 'activeEnergyBurned' | 'appleExerciseTime' | 'basalEnergyBurned' | 'bloodGlucose' | 'distanceCycling' | 'distanceWalkingRunning' | 'flightsClimbed' | 'heartRate' | 'weight'

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago