OneManage Logo
OneManage Docs

Install the SDK

Version: 0.0.1_alpha Group ID: io.github.iammohdzaki.onemanage.kmp Platforms: Android · iOS (arm64, x64, simulatorArm64) · JVM (Desktop)

Prerequisites

Before integrating the SDK, make sure you have:

  • A Kotlin Multiplatform project (Kotlin 2.0+)
  • Android minSdk 21+
  • iOS target (arm64 / x64 / simulatorArm64)
  • A OneManage account — get your API Key and App ID from the OneManage Dashboard

Add the Dependency

Step 1 — Version Catalog (gradle/libs.versions.toml)

[versions]
onemanage = "0.0.1_alpha"

[libraries]
onemanage = { module = "io.github.iammohdzaki.onemanage.kmp:onemanage", version.ref = "onemanage" }

Step 2 — Build Script (composeApp/build.gradle.kts)

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation(libs.onemanage)
        }
    }
}

KMP multiplatform note: The SDK publishes separate platform artifacts (e.g. onemanage-iosarm64, onemanage-jvm). You only need the base onemanage artifact in commonMain — the Kotlin toolchain resolves the correct platform artifact automatically via Gradle metadata.


Initialize the SDK

Initialization is idempotent — calling it more than once is a safe no-op. It must be called once before any feature is used.

Android

Initialize in your Application.onCreate():

// androidMain — MyApp.kt
import android.app.Application
import com.onemanage.OneManage
import com.onemanage.OneManageConfig

class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()

        OneManage.initialize(
            context = this,                   // Android Context — typealias to PlatformContext
            config  = OneManageConfig(
                apiKey        = "sk-live-xxxx",
                appId         = "my-android-app",
                enableLogging = BuildConfig.DEBUG  // true in debug, false in release
            )
        )
    }
}

Register your Application class in AndroidManifest.xml:

<application
    android:name=".MyApp"
    .../>

iOS

Create a concrete PlatformContext subclass (the expect class is abstract on iOS) and call initialize from your AppDelegate or SwiftUI @main:

// iosMain — or called from Swift via the generated framework
import OneManageSDK

// 1. Subclass the abstract PlatformContext
class IosPlatformContext: PlatformContext {}

// 2. AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        let config = OneManageConfig(
            apiKey: "sk-live-xxxx",
            appId: "my-ios-app",
            enableLogging: true
        )
        OneManage.shared.initialize(
            context: IosPlatformContext(),
            config: config
        )
        return true
    }
}

The iOS framework is named OneManageSDK (static framework). It is produced automatically when building with Xcode or via ./gradlew assembleXCFramework.

JVM / Desktop

On the JVM (Compose Desktop), PlatformContext is an abstract class. Create a concrete subclass and pass it in:

// jvmMain — main.kt
import com.onemanage.OneManage
import com.onemanage.OneManageConfig
import com.onemanage.internal.PlatformContext

// Concrete JVM context — no fields needed
class DesktopContext : PlatformContext()

fun main() = application {
    OneManage.initialize(
        context = DesktopContext(),
        config  = OneManageConfig(
            apiKey        = "sk-live-xxxx",
            appId         = "my-desktop-app",
            enableLogging = true
        )
    )

    Window(onCloseRequest = ::exitApplication, title = "My App") {
        App()
    }
}

Observing SDK State

OneManage.state is a StateFlow<SdkState> you can collect to react to initialization lifecycle events.

// commonMain (shared ViewModel, for example)
import com.onemanage.OneManage
import com.onemanage.SdkState
import kotlinx.coroutines.flow.collectLatest

viewModelScope.launch {
    OneManage.state.collectLatest { state ->
        when (state) {
            SdkState.UNINITIALIZED -> { /* SDK not started yet */ }
            SdkState.INITIALIZING  -> { /* Validating credentials with server */ }
            SdkState.INITIALIZED   -> { /* Ready — all features available */ }
            SdkState.FAILED        -> { /* Invalid API Key or App ID */ }
        }
    }
}
State Meaning
UNINITIALIZED initialize() has not been called
INITIALIZING Credentials are being validated with the server
INITIALIZED SDK is fully ready
FAILED Server returned 401/403 — check your API key and App ID

You can also check synchronously:

if (OneManage.isInitialized) {
    OneManage.logger.info("App", "Started")
}

Best practice: Don't gate every feature call behind isInitialized. Call initialize() early and let the SDK buffer or throw a clear IllegalStateException if used too early.


User Identity

By default the SDK assigns an anonymous UUID to each installation. Call setUserId after login to attribute all subsequent logs and bug reports to the authenticated user.

// After successful login
OneManage.setUserId("user_123456")

// On logout — revert to anonymous
OneManage.setUserId(null)

User identity is reflected automatically in all log batches and bug reports — no extra code needed per feature.


Published Artifacts

All artifacts share Group ID io.github.iammohdzaki.onemanage.kmp:

Artifact Target
onemanage KMP metadata (use this in commonMain)
onemanage-android Android release
onemanage-android-debug Android debug
onemanage-iosarm64 iOS physical device
onemanage-iossimulatorarm64 iOS Simulator (Apple Silicon)
onemanage-iosx64 iOS Simulator (Intel)
onemanage-jvm JVM / Desktop