Initialize Appxiom in Kotlin Multiplatform
Appxiom must be initialized separately in both the Android and iOS host applications. This connects the platform-native diagnostic engines with your Appxiom dashboard credentials.
Obtaining Dashboard Keys
Before initializing, obtain your application credentials from the Appxiom dashboard:
- Log in to app.appxiom.com.
- Click the
+icon at the top left to create an application. - Link your Android Application ID (e.g.
com.example.app) and copy your AndroidApp KeyandPlatform Key. - Link your iOS Bundle Identifier (e.g.
com.example.app) and copy your iOSApp KeyandPlatform Key(and iPadOS keys if targeting iPad).
Android Initialization
1. Initialize in Application.onCreate
Create or update your Android Application class:
package com.example.app
import android.app.Application
import tech.appxiom.kmp.Ax
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
// Initialize Appxiom telemetry engine with your Android dashboard keys
Ax.init(
context = this,
appKey = "YOUR_ANDROID_APP_KEY",
platformKey = "YOUR_ANDROID_PLATFORM_KEY"
)
}
}
2. Register in AndroidManifest.xml
Ensure your custom Application class is registered in androidMain/AndroidManifest.xml:
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:theme="@android:style/Theme.Material.Light.NoActionBar">
<!-- activities -->
</application>
iOS Initialization
1. Configure Info.plist
Open your iOS target's Info.plist (typically iosApp/iosApp/Info.plist) and add the AX configuration dictionary:
<key>AX</key>
<dict>
<!-- Keys for iOS -->
<key>AppKey</key>
<string>YOUR_IOS_APP_KEY</string>
<key>PlatformKey</key>
<string>YOUR_IOS_PLATFORM_KEY</string>
<!-- Keys for iPadOS (optional) -->
<key>AppKeyIpad</key>
<string>YOUR_IPADOS_APP_KEY</string>
<key>PlatformKeyIpad</key>
<string>YOUR_IPADOS_PLATFORM_KEY</string>
</dict>
2. Initialize from SwiftUI or UIKit
In SwiftUI (iosApp/iosApp/iOSApp.swift):
import SwiftUI
import ComposeApp
@main
struct iOSApp: App {
init() {
// Reads AppKey and PlatformKey automatically from Info.plist
Ax.shared.startIOS()
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
In UIKit (AppDelegate.swift):
import UIKit
import ComposeApp
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
Ax.shared.startIOS()
return true
}
}
Or from shared Kotlin code in iosMain:
import tech.appxiom.kmp.Ax
fun initializeIosAppxiom() {
Ax.startIOS()
}
Common Telemetry APIs
Once initialized, call these APIs from shared commonMain code:
1. User & Device Identification
Attach a custom identifier (such as a user ID, customer UUID, or account number up to 256 characters) to associate crashes, breadcrumbs, and goals:
import tech.appxiom.kmp.Ax
// Call after user login or authentication
Ax.setCustomId("user_849201")
2. Geographic Context
Attach user coordinates if your application already requests and manages location permissions:
import tech.appxiom.kmp.Ax
// Note: Appxiom does not request location permissions directly
Ax.setCurrentPosition(latitude = 37.7749, longitude = -122.4194)
3. Debug SDK Logging
Enable internal SDK logging during local development:
import tech.appxiom.kmp.Ax
// Activates verbose SDK diagnostics (remove before production release)
Ax.logMe()
Next Steps
Configure Android release builds with ProGuard & R8 Rules, or test dashboard connectivity with Verify Integration.