Android SDK
Kotlin SDK for Android apps. Same surface as iOS: configure → attribute → identify → pass the affiliate into RevenueCat.
Install (Gradle)
// build.gradle.kts (module)
dependencies {
implementation("com.myappaffiliate:sdk:0.1.0")
}The SDK is a plain Kotlin library — no Play Services dependency, minSdk 24.
Configure (once, in Application.onCreate)
import com.myappaffiliate.sdk.AffiliateSdk
class App : Application() {
override fun onCreate() {
super.onCreate()
AffiliateSdk.configure(
context = this,
apiKey = "pk_live_…", // your app's SDK key
baseUrl = "https://api.myappaffiliate.com",
)
}
}The SDK persists a generated device id in SharedPreferences (encrypted where
available) — no advertising id, no fingerprinting.
Attribute
App Link — handle the incoming intent and hand the SDK the URI (it extracts the
claim_token/ct param itself):
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { AffiliateSdk.attribute(it) }
}Manual code (reliable everywhere — a creator's "LUMI"):
AffiliateSdk.applyCode("LUMI")Install Referrer (deferred deep links)
If the user clicked a link but installed via the Play Store, the intent URI is lost.
Recover the claim token with the Play Install Referrer API: add
com.android.installreferrer:installreferrer:2.2 and, on first launch, read the
referrer string — the link service puts claim_token=<uuid> in it — then call
AffiliateSdk.attribute(...) with it. This is optional; the referral-code path needs
none of it.
Identify the user
Use the same id you pass to RevenueCat (Purchases.sharedInstance.logIn(...)):
AffiliateSdk.identify(userId)Pass the affiliate into RevenueCat
Set the subscriber attribute before the purchase:
import com.revenuecat.purchases.Purchases
AffiliateSdk.attributedAffiliateId()?.let { aff ->
Purchases.sharedInstance.setAttributes(mapOf("affiliate_id" to aff))
}API
| Call | Purpose |
|---|---|
AffiliateSdk.configure(context, apiKey, baseUrl) | Initialize once at launch |
AffiliateSdk.attribute(uri) | Record attribution from an App Link / referrer |
AffiliateSdk.applyCode(code) | Manual-code attribution fallback |
AffiliateSdk.identify(userId) | Bind your user id to the attribution |
AffiliateSdk.attributedAffiliateId() | The attributed affiliate id (or null) |
All network calls run off the main thread and are silent-safe — failures return
false/null and never crash the host app.