Implement Observer mode in Kotlin Multiplatform SDK
If you already have your own purchase infrastructure and aren’t ready to fully switch to Adapty, you can explore Observer mode. In its basic form, Observer Mode offers advanced analytics and seamless integration with attribution and analytics systems.
If this meets your needs, you only need to:
- Turn it on when configuring the Adapty SDK by setting the
observerModeparameter totrue. Follow the setup instructions for Kotlin Multiplatform. - Report transactions from your existing purchase infrastructure to Adapty.
In SDK v4, you can also present Adapty-rendered flows and paywalls in Observer mode: register an AdaptyUIObserverModeResolver with setObserverModeResolver to perform the purchase or restore with your own code when a user taps the corresponding button. See Present flows in Observer mode.
Observer mode setup
Turn on the Observer mode if you handle purchases and subscription status yourself and use Adapty for sending subscription events and analytics.
When running in Observer mode, Adapty SDK won’t close any transactions, so make sure you’re handling it.
import com.adapty.kmp.Adapty
import com.adapty.kmp.models.AdaptyConfig
val config = AdaptyConfig
.Builder("PUBLIC_SDK_KEY")
.withObserverMode(true) // default false
.build()
Adapty.activate(configuration = config)
.onSuccess {
Log.d("Adapty", "SDK initialised in observer mode")
}
.onError { error ->
Log.e("Adapty", "Adapty init error: ${error.message}")
}
Parameters:
| Parameter | Description |
|---|---|
| observerMode | A boolean value that controls Observer mode. The default value is false. |
Using Adapty flows & paywalls in Observer Mode
If you also want to use Adapty’s flows, paywalls, and A/B testing features, you can — but it requires some extra setup in Observer mode. Here’s what you’ll need to do in addition to the steps above:
- Display remote config paywalls as usual. For flows & paywalls built in the Flow Builder, see Present flows in Observer mode.
- Associate flows & paywalls with purchase transactions.