Skip to content

Quick Start

Get started with the Ascend Android SDK in just a few steps.


import android.app.Application
import android.util.Log
import com.application.ascend_android.*
import com.google.gson.JsonObject
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
val httpConfig = HttpConfig(
apiBaseUrl = "http://localhost:8100", // Replace with your actual API endpoint
)
val experimentConfig = ExperimentConfig.Builder(object : IExperimentCallback {
override fun onSuccess() {
// Called when experiments are successfully fetched
}
override fun onFailure(throwable: Throwable) {
// Called when experiment fetch fails
}
})
.defaultValues(hashMapOf("button_color" to JsonObject().apply { addProperty("color", "blue") }))
.shouldFetchOnInit(true) // Fetch experiments immediately on initialization
.httpConfig(httpConfig)
.build()
val experimentPluginConfig = PluginConfig(::DRSPlugin, Plugins.EXPERIMENTS.pluginName, experimentConfig)
val ascendConfig = AscendConfig(httpConfig, arrayListOf(experimentPluginConfig), ClientConfig("your-key")) // Replace with your actual API key
Ascend.init(ascendConfig, this)
Ascend.user.setUser("user123") // Replace with your actual user ID
}
}

val experimentPlugin = Ascend.getPlugin<DRSPlugin>(Plugins.EXPERIMENTS)
val buttonColor = experimentPlugin.getExperimentService()
.getStringFlag("button_color", "color")
button.setBackgroundColor(Color.parseColor(buttonColor))

Coming soon…