Guides

Configure the SDK Settings

In this guide we will teach you how to prepare the Sahha SDK for correct use, configure the environment settings, connect to device sensors and handle notifications.

The Sahha SDK must be configured immediately upon app launch.


import sdk.sahha.android.source.*
// Configure Sahha inside `onCreate` of your app's `MainActivity`.
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// You can specify optional custom notification settings
val notificationSettings = SahhaNotificationConfiguration(
icon = R.drawable.ic_test, // The icon id must match the filename you add to the project
title = "Custom Title",
shortDescription = "Custom description",
)
val settings = SahhaSettings (
environment = SahhaEnvironment.sandbox,
notificationSettings = notificationSettings, // Optional - defaults to null
sensors = [.heart, .sleep], // Optional - defaults to all avaialable sensors
)
Sahha.configure(application, settings) { error, success ->
if (error != null) {
println(error)
} else {
println(success.toString())
}
}
}
}

Environment Settings

Sahha has two servers, one for development and one for production. We recommend using the development environment until you're ready to go live. The SahhaEnvironment determines if the SDK connects to the sandbox or production server of the API.

SahhaEnvironment Description
sandbox For testing and debugging
production For public release on the App Store / Google Play

Setting the incorrect environment will send data to the wrong server!

  • Always use sandbox during development of your app.
  • Only use production when releasing your app to public users (not for internal testing) .
enum class SahhaEnvironment {
sandbox,
production
}

Sensor Settings

You can specify which sensors for the Sahha SDK to use. We suggest asking the user for permission for access to only the sensors that your app needs. This will lower the chance that the user will reject your permission request.

Choose if you want to request permission for all, some, or no sensors.

If you leave the Sensor Settings value to the default value of null, ALL AVAILABLE SENSORS will be requested.

If you set the Sensor Settings value to an array of some specific sensors, ONLY THOSE SENSORS will be requested.

If you set the Sensor Settings value to an empty array [], NO SENSORS be requested.

Some sensors are not available on all platforms.

SahhaSensor Android Permissions iOS Permissions
sleep SleepSession SleepAnalysis
activity Steps, FloorsClimbed StepCount, FlightsClimbed, MoveTime, StandTime, ExerciseTime, ActivitySummary
device PhysicalActivity X
heart HeartRate, RestingHeartRate, HeartRateVariabilityRmssd HeartRate, RestingHeartRate, WalkingHeartRateAverage, HeartRateVariabilitySDNN
blood BloodPressure, BloodGlucose BloodPressureSystolic, BloodPressureDiastolic, BloodGlucose
oxygen OxygenSaturation, RespiratoryRate, Vo2Max VO2Max, OxygenSaturation, RespiratoryRate
energy ActiveCaloriesBurned, BasalMetabolicRate, TotalCaloriesBurned ActiveEnergyBurned, BasalEnergyBurned, TimeInDaylight
body Height, Weight, BodyFat, BodyWaterMass, BoneMass, LeanBodyMass Height, Weight, LeanBodyMass, BodyMassIndex, BodyFat, WaistCircumference
temperature BodyTemperature, BasalBodyTemperature BodyTemperature, BasalBodyTemperature, AppleSleepingWristTemperature
exercise Exercise Workout

enum class SahhaSensor {
device,
sleep,
activity,
heart,
blood,
oxygen,
energy,
body,
temperature,
exercise
}

(Android) Uses Permission - IMPORTANT INFO

Configuring Sensors for Android

In addition to including your required sensor values via the SDK Configure method, you will also need to include matching uses-permission values for each required sensor in your AndroidManifest.xml.

View the SDK Integration guide for Android .

If the values do not match, you are likely to receive build errors and risk your app being rejected on the Google Play Store!


Notification Settings

You can customize notifications for any platform that includes an Android app.

You can customize notifications for the following platforms:

  • Android
  • Flutter (Android only)
  • React Native (Android only)

iOS apps not supported


Custom Notification Icon

You can add an optional custom notification icon to your Android app.

How to create app icons with Image Asset Studio

How to create app icons with Image Asset Studio

Click here for more info

Step 1) Open your project in Android Studio.

Custom Notifications

Step 2) With the app folder highlighted, select FileNewImage Asset.

Custom Notifications

Step 3) Select Notification Icons for Icon Type, enter a Name, select Image as Asset Type and alter the Padding as desired.

Custom Notifications

Step 4) This page can typically be left as it is. Select Finish.

Custom Notifications


Custom Notification Settings

You can specify optional custom notificationSettings. If notificationSettings are not specified, then the app will use the default notification settings.

val notificationSettings = SahhaNotificationConfiguration(
icon = R.drawable.ic_test, // The icon id must match the filename you add to the project
title = "Custom Title",
shortDescription = "Custom description",
)

Default Notification Settings

If custom notificationSettings are not specified, then the app will use the default notification settings. If custom notificationSettings are only partially specified, then the app will use the default notification settings. The app will fill in the missing notification parameters with default values. E.g. if an icon and title are provided but a shortDescription is not, then the shortDescription will use the default value.

val icon = R.drawable.ic_sahha_no_bg // The Sahha logo
val title = "Gathering health insights"
val shortDescription = "Swipe for options to hide this notification."