Configure the Sahha SDK for correct use, choose environment settings, and handle notifications.


Configure

The Sahha SDK must be configured immediately upon app launch.

Swift
import SwiftUI
import Sahha

@main
struct MyApp: App {

  // Configure Sahha inside `init` of your app's `App` view.

  init() {
    let settings = SahhaSettings(
      environment: .sandbox, // Required - .sandbox for testing
    )
    Sahha.configure(settings) {
      // SDK is ready to use
      print("SDK Ready")
    }
  }

  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }

}

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.

SahhaEnvironmentDescription
sandboxFor testing and debugging
productionFor 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).
Swift
public enum SahhaEnvironment: String {
    case sandbox
    case production
}

Notification Settings

Calling the Configure() function will request notification permissions if they are not already enabled. If you are not already handling notifications elsewhere in onboarding, plan when you call configure(). Depending on your integration flow, configure() may be the first SDK-related permission step the user sees.

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.

Step 2) With the app folder highlighted, selectFile → New → Image Asset.

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

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


Custom Notification Settings

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

Android
Kotlin
val notificationSettings = SahhaNotificationConfiguration(
    iconResourceId = 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:

Android
Kotlin
// SahhaNotificationConfiguration.DEFAULT
SahhaNotificationConfiguration(
    iconResourceId = R.drawable.ic_sahha_no_bg, // The Sahha logo
    title = "Gathering health insights",
    shortDescription = "Swipe for options to hide this notification.",
)

When you set custom notificationSettings, set all three values: the icon, title and shortDescription. In Kotlin, SahhaNotificationConfiguration needs all three, so to keep some of the defaults, copy SahhaNotificationConfiguration.DEFAULT and replace the values you want to change:

Android
Kotlin
val notificationSettings = SahhaNotificationConfiguration.DEFAULT.copy(
    title = "Syncing your health data",
    shortDescription = "This notification closes when the sync is done.",
)
Docs