@pianissimoproject/capacitor-health-connect
v0.7.1
Published
Android Health Connect integration for Capacitor
Downloads
191
Readme
capacitor-health-connect
Android Health Connect integration for Capacitor
🛠️ Modified by LIH: This fork has been updated by the Luxembourg Institute of Health (LIH) to support Capacitor 7 and Android SDK 21+ (Java) compatibility.
Install
npm install capacitor-health-connect
npx cap sync androidUsage
import { HealthConnect } from 'capacitor-health-connect';
const healthConnectAvailability = await HealthConnect.checkAvailability();API
checkAvailability()insertRecords(...)readRecord(...)readRecords(...)getChangesToken(...)getChanges(...)requestHealthPermissions(...)checkHealthPermissions(...)revokeHealthPermissions()openHealthConnectSetting()- Interfaces
- Type Aliases
checkAvailability()
checkAvailability() => Promise<{ availability: HealthConnectAvailability; }>Returns: Promise<{ availability: HealthConnectAvailability; }>
insertRecords(...)
insertRecords(options: { records: Record[]; }) => Promise<{ recordIds: string[]; }>| Param | Type |
| ------------- | ----------------------------------- |
| options | { records: Record[]; } |
Returns: Promise<{ recordIds: string[]; }>
readRecord(...)
readRecord(options: { type: RecordType; recordId: string; }) => Promise<{ record: StoredRecord; }>| Param | Type |
| ------------- | ------------------------------------------------------------------------------ |
| options | { type: RecordType; recordId: string; } |
Returns: Promise<{ record: StoredRecord; }>
readRecords(...)
readRecords(options: { type: RecordType; timeRangeFilter: TimeRangeFilter; dataOriginFilter?: string[]; ascendingOrder?: boolean; pageSize?: number; pageToken?: string; }) => Promise<{ records: StoredRecord[]; pageToken?: string; }>| Param | Type |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| options | { type: RecordType; timeRangeFilter: TimeRangeFilter; dataOriginFilter?: string[]; ascendingOrder?: boolean; pageSize?: number; pageToken?: string; } |
Returns: Promise<{ records: StoredRecord[]; pageToken?: string; }>
getChangesToken(...)
getChangesToken(options: { types: RecordType[]; }) => Promise<{ token: string; }>| Param | Type |
| ------------- | ------------------------------------- |
| options | { types: RecordType[]; } |
Returns: Promise<{ token: string; }>
getChanges(...)
getChanges(options: { token: string; }) => Promise<{ changes: Change[]; nextToken: string; }>| Param | Type |
| ------------- | ------------------------------- |
| options | { token: string; } |
Returns: Promise<{ changes: Change[]; nextToken: string; }>
requestHealthPermissions(...)
requestHealthPermissions(options: { read: RecordType[]; write: RecordType[]; }) => Promise<{ grantedPermissions: string[]; hasAllPermissions: boolean; }>| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | { read: RecordType[]; write: RecordType[]; } |
Returns: Promise<{ grantedPermissions: string[]; hasAllPermissions: boolean; }>
checkHealthPermissions(...)
checkHealthPermissions(options: { read: RecordType[]; write: RecordType[]; }) => Promise<{ grantedPermissions: string[]; hasAllPermissions: boolean; }>| Param | Type |
| ------------- | --------------------------------------------------------- |
| options | { read: RecordType[]; write: RecordType[]; } |
Returns: Promise<{ grantedPermissions: string[]; hasAllPermissions: boolean; }>
revokeHealthPermissions()
revokeHealthPermissions() => Promise<void>openHealthConnectSetting()
openHealthConnectSetting() => Promise<void>Interfaces
Date
Enables basic storage and retrieval of dates and times.
| Method | Signature | Description | | ---------------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------- | | toString | () => string | Returns a string representation of a date. The format of the string depends on the locale. | | toDateString | () => string | Returns a date as a string value. | | toTimeString | () => string | Returns a time as a string value. | | toLocaleString | () => string | Returns a value as a string value appropriate to the host environment's current locale. | | toLocaleDateString | () => string | Returns a date as a string value appropriate to the host environment's current locale. | | toLocaleTimeString | () => string | Returns a time as a string value appropriate to the host environment's current locale. | | valueOf | () => number | Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. | | getTime | () => number | Gets the time value in milliseconds. | | getFullYear | () => number | Gets the year, using local time. | | getUTCFullYear | () => number | Gets the year using Universal Coordinated Time (UTC). | | getMonth | () => number | Gets the month, using local time. | | getUTCMonth | () => number | Gets the month of a Date object using Universal Coordinated Time (UTC). | | getDate | () => number | Gets the day-of-the-month, using local time. | | getUTCDate | () => number | Gets the day-of-the-month, using Universal Coordinated Time (UTC). | | getDay | () => number | Gets the day of the week, using local time. | | getUTCDay | () => number | Gets the day of the week using Universal Coordinated Time (UTC). | | getHours | () => number | Gets the hours in a date, using local time. | | getUTCHours | () => number | Gets the hours value in a Date object using Universal Coordinated Time (UTC). | | getMinutes | () => number | Gets the minutes of a Date object, using local time. | | getUTCMinutes | () => number | Gets the minutes of a Date object using Universal Coordinated Time (UTC). | | getSeconds | () => number | Gets the seconds of a Date object, using local time. | | getUTCSeconds | () => number | Gets the seconds of a Date object using Universal Coordinated Time (UTC). | | getMilliseconds | () => number | Gets the milliseconds of a Date, using local time. | | getUTCMilliseconds | () => number | Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). | | getTimezoneOffset | () => number | Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). | | setTime | (time: number) => number | Sets the date and time value in the Date object. | | setMilliseconds | (ms: number) => number | Sets the milliseconds value in the Date object using local time. | | setUTCMilliseconds | (ms: number) => number | Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC). | | setSeconds | (sec: number, ms?: number | undefined) => number | Sets the seconds value in the Date object using local time. | | setUTCSeconds | (sec: number, ms?: number | undefined) => number | Sets the seconds value in the Date object using Universal Coordinated Time (UTC). | | setMinutes | (min: number, sec?: number | undefined, ms?: number | undefined) => number | Sets the minutes value in the Date object using local time. | | setUTCMinutes | (min: number, sec?: number | undefined, ms?: number | undefined) => number | Sets the minutes value in the Date object using Universal Coordinated Time (UTC). | | setHours | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number | Sets the hour value in the Date object using local time. | | setUTCHours | (hours: number, min?: number | undefined, sec?: number | undefined, ms?: number | undefined) => number | Sets the hours value in the Date object using Universal Coordinated Time (UTC). | | setDate | (date: number) => number | Sets the numeric day-of-the-month value of the Date object using local time. | | setUTCDate | (date: number) => number | Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC). | | setMonth | (month: number, date?: number | undefined) => number | Sets the month value in the Date object using local time. | | setUTCMonth | (month: number, date?: number | undefined) => number | Sets the month value in the Date object using Universal Coordinated Time (UTC). | | setFullYear | (year: number, month?: number | undefined, date?: number | undefined) => number | Sets the year of the Date object using local time. | | setUTCFullYear | (year: number, month?: number | undefined, date?: number | undefined) => number | Sets the year value in the Date object using Universal Coordinated Time (UTC). | | toUTCString | () => string | Returns a date converted to a string using Universal Coordinated Time (UTC). | | toISOString | () => string | Returns a date as a string value in ISO format. | | toJSON | (key?: any) => string | Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. |
Type Aliases
HealthConnectAvailability
'Available' | 'NotInstalled' | 'NotSupported'
Record
Construct a type with a set of properties K of type T
{ [P in K]: T; }
StoredRecord
RecordBase & Record
RecordBase
{ metadata: RecordMetadata; }
RecordMetadata
{ id: string; clientRecordId?: string; clientRecordVersion: number; lastModifiedTime: Date; dataOrigin: string; }
RecordType
'ActiveCaloriesBurned' | 'BasalBodyTemperature' | 'BasalMetabolicRate' | 'BloodGlucose' | 'BloodPressure' | 'BodyFat' | 'BodyTemperature' | 'HeartRateSeries' | 'Height' | 'OxygenSaturation' | 'RespiratoryRate' | 'RestingHeartRate' | 'Steps' | 'Weight'
TimeRangeFilter
{ type: 'before' | 'after'; time: Date; } | { type: 'between'; startTime: Date; endTime: Date; }
Change
{ type: 'Upsert'; record: Record; } | { type: 'Delete'; recordId: string; }
