Configuration
You will need to configure the Sahha SDK before you can use it.
The Sahha SDK must be configured immediately on app launch.
Configure
Choose your specific platform from the options below.
- iOS (SwiftUI)
- iOS (UIKit)
- Android
- Flutter
- React Native
import SwiftUI
import Sahha
@main
struct MyApp: App {
// Configure Sahha inside `init` of your app's `App` view.
init() {
let settings = SahhaSettings(environment: .sandbox)
Sahha.configure(settings) {
// SDK is ready to use
print("SDK Ready")
}
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
import UIKit
import Sahha
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
// Configure Sahha inside `application didFinishLaunchingWithOptions` of your app's `AppDelegate`.
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
let settings = SahhaSettings(
environment: .sandbox, // Required - .sandbox for testing
sensors: [.sleep] // Optional - defaults to all sensors
)
Sahha.configure(settings) {
// SDK is ready to use
print("SDK Ready")
}
return true
}
}
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 = [.pedometer, .sleep], // Optional - defaults to all avaialable sensors
)
Sahha.configure(application, settings) { error, success ->
if (error != null) {
println(error)
} else {
println(success.toString())
}
}
}
}
import 'package:sahha_flutter/sahha_flutter.dart';
class _MyAppState extends State<MyApp> {
void initState() {
super.initState();
// Configure Sahha inside `initState` of your app's `AppState`.
// Optional - Android only
var notificationSettings = {
'icon': 'Custom Icon',
'title': 'Custom Title',
'shortDescription': 'Custom Description'
};
// Use custom values
SahhaFlutter.configure(
environment: SahhaEnvironment.sandbox, // Required - .sandbox for testing
sensors: [SahhaSensor.device] // Optional - defaults to all sensors
.then((success) => {
debugPrint(success.toString())
})
.catchError((error, stackTrace) => {
debugPrint(error.toString())
});
}
}
import React, { useEffect } from 'react';
import Sahha, { SahhaEnvironment, SahhaSensor } from "sahha-react-native";
export default function App() {
useEffect(() => {
// Configure Sahha inside the `useEffect` of your App's `export function`.
// Use custom values
const settings = {
environment: SahhaEnvironment.sandbox, // Required - .sandbox for testing
// Optional - Android only
notificationSettings: {
icon: "ic_test",
title: "Test Title",
shortDescription: "Test description.",
},
sensors: [SahhaSensor.sleep, SahhaSensor.pedometer], // Optional - defaults to all sensors
};
Sahha.configure(settings, (error: string, success: boolean) => {
console.log(`Success: ${success}`);
if (error) {
console.error(`Error: ${error}`);
}
});
}, []);
}
Environment Settings
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 |
- Always use
sandbox
during development of your app. - Only use
production
when releasing your app to public users (not for internal testing).
- iOS
- Android
- Flutter
- React Native
public enum SahhaEnvironment: String {
case sandbox
case production
}
enum class SahhaEnvironment {
sandbox,
production
}
enum SahhaEnvironment {
sandbox,
production
}
enum SahhaEnvironment {
sandbox,
production
}
Sensor Settings
You can specify which sensors for the Sahha SDK to use. To optimize your analysis result, we suggest enabling all sensors. Leave this value null to enable all sensors by default.
Some sensors are not available on all platforms.
SahhaSensor | Description | Android | iOS |
---|---|---|---|
sleep | For tracking sleep patterns | ✓ | ✓ |
pedometer | For tracking walking patterns | ✓ | ✓ |
device | For tracking device usage patterns | ✓ | X |
heart | For tracking heart patterns (rate, variability) | X | ✓ |
blood | For tracking blood patterns (pressure, glucose) | X | ✓ |
- iOS
- Android
- Flutter
- React Native
public enum SahhaSensor: String, CaseIterable {
case sleep
case pedometer
case device
case heart
case blood
}
enum class SahhaSensor {
device,
sleep,
pedometer,
heart,
blod
}
enum SahhaSensor {
sleep,
pedometer,
device,
heart,
blood
}
enum SahhaSensor {
sleep,
pedometer,
device,
heart,
blood
}
Notifications
You can customize notifications for any platform that includes an Android app.
- 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.
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.
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 = "Analytics are running"
val shortDescription = "Swipe for options to hide this notification."