0.0.4 • Published 2 years ago

capacitor-health-data-plugin v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

capacitor-health-data-plugin

capacitor plugin that uses sensors for retrieving health-related data

Install

npm install capacitor-health-data-plugin
npx cap sync

API

Plugin for accessing health data and step counters.

echo(...)

echo(options: { value: string; }) => Promise<{ value: string; }>

Echoes back the provided value.

ParamTypeDescription
options{ value: string; }- The options object.

Returns: Promise<{ value: string; }>


getSteps()

getSteps() => Promise<{ name: string; count: number; }>

Retrieves the step count value from the step counter sensor since it was started. Returns null if the necessary permissions have not been granted. Once the permissions are granted, subsequent calls will return the correct step count value. If the device doesn't have a step counter sensor, it won't return anything, but a message indicating that the sensor is not available will be logged to the console.

Returns: Promise<{ name: string; count: number; }>


getHeartRate()

getHeartRate() => Promise<{ name: string; count: number; }>

Retrieves the heart rate value from the heart rate sensor. Returns null if the necessary permissions have not been granted. Once the permissions are granted, subsequent calls will return the correct step count value. If the device doesn't have a step counter sensor, it won't return anything, but a message indicating that the sensor is not available will be logged to the console.

Returns: Promise<{ name: string; count: number; }>


checkPermission(...)

checkPermission(options?: CheckPermissionOptions | undefined) => Promise<CheckPermissionResult>

Checks the status of the permission and requests it for the first time if it hasn't been granted. The permission status remains unchanged once it has been granted for the rest of the application usage.

ParamTypeDescription
optionsCheckPermissionOptions- The options object.

Returns: Promise<CheckPermissionResult>


openAppSettings()

openAppSettings() => Promise<void>

Opens the app settings screen for the current app.


Interfaces

CheckPermissionResult

PropTypeDescriptionSince
grantedbooleanWhen set to true, the permission is granted.
deniedbooleanWhen set to true, the permission is denied and cannot be prompted for. The openAppSettings method should be used to let the user grant the permission.0.0.1
askedbooleanWhen this is set to true, the user was just prompted the permission. Ergo: a dialog, asking the user to grant the permission, was shown.0.0.1
neverAskedbooleanWhen this is set to true, the user has never been prompted the permission.0.0.1
restrictedbooleaniOS only When this is set to true, the permission cannot be requested for some reason.0.0.1
unknownbooleaniOS only When this is set to true, the permission status cannot be retrieved.0.0.1

CheckPermissionOptions

PropTypeDescriptionDefaultSince
forcebooleanIf this is set to true, the user will be prompted for the permission. The prompt will only show if the permission was not yet granted and also not denied completely yet.false0.0.1
0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago