Android SDK
Native Kotlin SDK for Android applications with deep link handling.
The Android SDK provides native Kotlin integration with automatic deep link handling, deferred deep links, and Play Install Referrer support.
Installation
dependencies {
implementation("com.referralengine:sdk:1.0.0")
}Initialization
import com.referralengine.sdk.ReferralEngine
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
ReferralEngine.configure(
context = this,
apiKey = "your_api_key",
options = REOptions(
enableDeepLinks = true,
enablePlayInstallReferrer = true
)
)
}
}Deep Link Handling
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
intent?.data?.let { uri ->
ReferralEngine.getInstance().handleDeepLink(uri) { result ->
result.onSuccess { referral ->
Log.d("Referral", "Referred by: ${referral.referrerUserId}")
}
}
}
}Generating Links
lifecycleScope.launch {
val result = ReferralEngine.getInstance().createLink(
userId = "user_123",
campaignId = "camp_abc"
)
result.onSuccess { link ->
val shareIntent = Intent(Intent.ACTION_SEND).apply {
type = "text/plain"
putExtra(Intent.EXTRA_TEXT, link.url)
}
startActivity(Intent.createChooser(shareIntent, "Share via"))
}
}The SDK automatically uses Play Install Referrer API for accurate install attribution.