Quick Start
Get started with the Ascend Android SDK in just a few steps.
Initialize the SDK
Section titled “Initialize the SDK”import android.app.Applicationimport android.util.Logimport 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 }}Use Experiments
Section titled “Use Experiments”val experimentPlugin = Ascend.getPlugin<DRSPlugin>(Plugins.EXPERIMENTS)
val buttonColor = experimentPlugin.getExperimentService() .getStringFlag("button_color", "color")
button.setBackgroundColor(Color.parseColor(buttonColor))Use Events
Section titled “Use Events”Coming soon…