sahha-capacitor
TypeScript icon, indicating that this package has built-in type declarations

1.1.7 • Public • Published

Sahha Capacitor SDK

The Sahha SDK provides a convenient way for Ionic / Capacitor apps to connect to the Sahha API.

Sahha lets your project seamlessly collect health and lifestyle data from smartphones and wearables via Apple Health, Google Health Connect, and a variety of other sources.

For more information on Sahha please visit https://sahha.ai.


Docs

The Sahha Docs provide detailed instructions for installation and usage of the Sahha SDK.

Sahha Docs


Example

The Sahha Demo App provides a convenient way to try the features of the Sahha SDK.

Sahha Demo App


Health Data Source Integrations

Sahha supports integration with the following health data sources:

& many more! Please visit our integrations page for more information.


Install

npm install sahha-capacitor
npx cap sync

Android

In the AndroidManifest.xml file, which can be found in android > app > src > main, declare Google Health Connect data types if required, e.g. sleep and step count.

More data types are available such as heart rate, workout / exercise, please refer to the links below for more information.

<!-- Sleep -->
<uses-permission android:name="android.permission.health.READ_SLEEP" />

  <!-- Activity -->
<uses-permission android:name="android.permission.health.READ_STEPS" />
<uses-permission android:name="android.permission.health.READ_FLOORS_CLIMBED" />

This is recommended if you'd like to retrieve Health Connect data from other health apps such as WHOOP, Garmin, Samsung Health etc.

To declare other sensor permissions, please refer to this page.

Only include the sensor permissions required by your project, what is declared here will be reviewed by the Play Store.

You must be able to justify reasons behind requiring the sensor permissions, these justifications may be used to clearly articulate the reasoning behind your required sensor permissions.

Apple iOS

Enable HealthKit

  • Open your project in Xcode and select your App Target in the Project panel.
  • Navigate to the Signing & Capabilities tab.
  • Click the + button (or choose Editor > Add Capability) to open the Capabilities library.
  • Locate and select HealthKit; double-click it to add it to your project.

Background Delivery

  • Select your project in the Project navigator and choose your app’s target.
  • In the Signing & Capabilities tab, find the HealthKit capability.
  • Enable the nested Background Delivery option to allow passive health data collection.

Add Usage Descriptions

  • Select your App Target and navigate to the Info tab.
  • Click the + button to add a new key and choose Privacy - Health Share Usage Description.
  • Provide a clear description, such as: "This app needs your health info to deliver mood predictions."

For more detailed instructions, refer to our setup guide.


API

configure(...)

configure(options: { settings: SahhaSettings; }) => Promise<{ success: boolean; }>
Param Type
options { settings: SahhaSettings; }

Returns: Promise<{ success: boolean; }>


isAuthenticated()

isAuthenticated() => Promise<{ success: boolean; }>

Returns: Promise<{ success: boolean; }>


authenticate(...)

authenticate(options: { appId: string; appSecret: string; externalId: string; }) => Promise<{ success: boolean; }>
Param Type
options { appId: string; appSecret: string; externalId: string; }

Returns: Promise<{ success: boolean; }>


authenticateToken(...)

authenticateToken(options: { profileToken: string; refreshToken: string; }) => Promise<{ success: boolean; }>
Param Type
options { profileToken: string; refreshToken: string; }

Returns: Promise<{ success: boolean; }>


deauthenticate()

deauthenticate() => Promise<{ success: boolean; }>

Returns: Promise<{ success: boolean; }>


getProfileToken()

getProfileToken() => Promise<{ profileToken?: string; }>

Returns: Promise<{ profileToken?: string; }>


getDemographic()

getDemographic() => Promise<{ demographic?: string; }>

Returns: Promise<{ demographic?: string; }>


postDemographic(...)

postDemographic(options: { demographic: SahhaDemographic; }) => Promise<{ success: boolean; }>
Param Type
options { demographic: SahhaDemographic; }

Returns: Promise<{ success: boolean; }>


getSensorStatus(...)

getSensorStatus(options: { sensors: SahhaSensor[]; }) => Promise<{ status: SahhaSensorStatus; }>
Param Type
options { sensors: SahhaSensor[]; }

Returns: Promise<{ status: SahhaSensorStatus; }>


enableSensors(...)

enableSensors(options: { sensors: SahhaSensor[]; }) => Promise<{ status: SahhaSensorStatus; }>
Param Type
options { sensors: SahhaSensor[]; }

Returns: Promise<{ status: SahhaSensorStatus; }>


getScores(...)

getScores(options: { types: SahhaScoreType[]; startDateTime: number; endDateTime: number; }) => Promise<{ value: string; }>
Param Type
options { types: SahhaScoreType[]; startDateTime: number; endDateTime: number; }

Returns: Promise<{ value: string; }>


getBiomarkers(...)

getBiomarkers(options: { categories: SahhaBiomarkerCategory[]; types: SahhaBiomarkerType[]; startDateTime: number; endDateTime: number; }) => Promise<{ value: string; }>
Param Type
options { categories: SahhaBiomarkerCategory[]; types: SahhaBiomarkerType[]; startDateTime: number; endDateTime: number; }

Returns: Promise<{ value: string; }>


getStats(...)

getStats(options: { sensor: SahhaSensor; startDateTime: number; endDateTime: number; }) => Promise<{ value: string; }>
Param Type
options { sensor: SahhaSensor; startDateTime: number; endDateTime: number; }

Returns: Promise<{ value: string; }>


getSamples(...)

getSamples(options: { sensor: SahhaSensor; startDateTime: number; endDateTime: number; }) => Promise<{ value: string; }>
Param Type
options { sensor: SahhaSensor; startDateTime: number; endDateTime: number; }

Returns: Promise<{ value: string; }>


openAppSettings()

openAppSettings() => Promise<void>

postSensorData()

postSensorData() => Promise<void>

Interfaces

SahhaSettings

Prop Type
environment SahhaEnvironment
sensors SahhaSensor[]
notificationSettings { icon?: string; title?: string; shortDescription?: string; }

SahhaDemographic

Prop Type
age number
gender string
country string
birthCountry string
ethnicity string
occupation string
industry string
incomeRange string
education string
relationship string
locale string
livingArrangement string
birthDate string

Enums

SahhaEnvironment

Members Value
sandbox 'sandbox'
production 'production'

SahhaSensor

Members Value
gender 'gender'
date_of_birth 'date_of_birth'
sleep 'sleep'
steps 'steps'
floors_climbed 'floors_climbed'
heart_rate 'heart_rate'
resting_heart_rate 'resting_heart_rate'
walking_heart_rate_average 'walking_heart_rate_average'
heart_rate_variability_sdnn 'heart_rate_variability_sdnn'
heart_rate_variability_rmssd 'heart_rate_variability_rmssd'
blood_pressure_systolic 'blood_pressure_systolic'
blood_pressure_diastolic 'blood_pressure_diastolic'
blood_glucose 'blood_glucose'
vo2_max 'vo2_max'
oxygen_saturation 'oxygen_saturation'
respiratory_rate 'respiratory_rate'
active_energy_burned 'active_energy_burned'
basal_energy_burned 'basal_energy_burned'
total_energy_burned 'total_energy_burned'
basal_metabolic_rate 'basal_metabolic_rate'
time_in_daylight 'time_in_daylight'
body_temperature 'body_temperature'
basal_body_temperature 'basal_body_temperature'
sleeping_wrist_temperature 'sleeping_wrist_temperature'
height 'height'
weight 'weight'
lean_body_mass 'lean_body_mass'
body_mass_index 'body_mass_index'
body_fat 'body_fat'
body_water_mass 'body_water_mass'
bone_mass 'bone_mass'
waist_circumference 'waist_circumference'
stand_time 'stand_time'
move_time 'move_time'
exercise_time 'exercise_time'
activity_summary 'activity_summary'
device_lock 'device_lock'
exercise 'exercise'
running_speed 'running_speed'
running_power 'running_power'
running_ground_contact_time 'running_ground_contact_time'
running_stride_length 'running_stride_length'
running_vertical_oscillation 'running_vertical_oscillation'
six_minute_walk_test_distance 'six_minute_walk_test_distance'
stair_ascent_speed 'stair_ascent_speed'
stair_descent_speed 'stair_descent_speed'
walking_speed 'walking_speed'
walking_steadiness 'walking_steadiness'
walking_asymmetry_percentage 'walking_asymmetry_percentage'
walking_double_support_percentage 'walking_double_support_percentage'
walking_step_length 'walking_step_length'

SahhaSensorStatus

Members Value
pending 0
unavailable 1
disabled 2
enabled 3

SahhaScoreType

Members Value
wellbeing 'wellbeing'
activity 'activity'
sleep 'sleep'
readiness 'readiness'
mental_wellbeing 'mental_wellbeing'

SahhaBiomarkerCategory

Members Value
activity 'activity'
body 'body'
characteristic 'characteristic'
reproductive 'reproductive'
sleep 'sleep'
vitals 'vitals'

SahhaBiomarkerType

Members Value
steps 'steps'
floors_climbed 'floors_climbed'
active_hours 'active_hours'
active_duration 'active_duration'
activity_low_intensity_duration 'activity_low_intensity_duration'
activity_mid_intensity_duration 'activity_mid_intensity_duration'
activity_high_intensity_duration 'activity_high_intensity_duration'
activity_sedentary_duration 'activity_sedentary_duration'
active_energy_burned 'active_energy_burned'
total_energy_burned 'total_energy_burned'
height 'height'
weight 'weight'
body_mass_index 'body_mass_index'
body_fat 'body_fat'
fat_mass 'fat_mass'
lean_mass 'lean_mass'
waist_circumference 'waist_circumference'
resting_energy_burned 'resting_energy_burned'
age 'age'
biological_sex 'biological_sex'
date_of_birth 'date_of_birth'
menstrual_cycle_length 'menstrual_cycle_length'
menstrual_cycle_start_date 'menstrual_cycle_start_date'
menstrual_cycle_end_date 'menstrual_cycle_end_date'
menstrual_phase 'menstrual_phase'
menstrual_phase_start_date 'menstrual_phase_start_date'
menstrual_phase_end_date 'menstrual_phase_end_date'
menstrual_phase_length 'menstrual_phase_length'
sleep_start_time 'sleep_start_time'
sleep_end_time 'sleep_end_time'
sleep_duration 'sleep_duration'
sleep_debt 'sleep_debt'
sleep_interruptions 'sleep_interruptions'
sleep_in_bed_duration 'sleep_in_bed_duration'
sleep_awake_duration 'sleep_awake_duration'
sleep_light_duration 'sleep_light_duration'
sleep_rem_duration 'sleep_rem_duration'
sleep_deep_duration 'sleep_deep_duration'
sleep_regularity 'sleep_regularity'
sleep_latency 'sleep_latency'
sleep_efficiency 'sleep_efficiency'
heart_rate_resting 'heart_rate_resting'
heart_rate_sleep 'heart_rate_sleep'
heart_rate_variability_sdnn 'heart_rate_variability_sdnn'
heart_rate_variability_rmssd 'heart_rate_variability_rmssd'
respiratory_rate 'respiratory_rate'
respiratory_rate_sleep 'respiratory_rate_sleep'
oxygen_saturation 'oxygen_saturation'
oxygen_saturation_sleep 'oxygen_saturation_sleep'
vo2_max 'vo2_max'
blood_glucose 'blood_glucose'
blood_pressure_systolic 'blood_pressure_systolic'
blood_pressure_diastolic 'blood_pressure_diastolic'
body_temperature_basal 'body_temperature_basal'
skin_temperature_sleep 'skin_temperature_sleep'

Copyright © 2024 Sahha. All rights reserved.

Readme

Keywords

Package Sidebar

Install

npm i sahha-capacitor

Weekly Downloads

81

Version

1.1.7

License

Sahha SDK License

Unpacked Size

213 kB

Total Files

24

Last publish

Collaborators

  • matt_sahha
  • min-sahha