SDK Install Referrer for Kotlin (version 7.0.0)
SDK Install Referrer is an attribution tool for advertising and analytics systems. It allows you to track the number of your application installations via advertising links.
RuStore accepts links in the format https://www.rustore.ru/catalog/app/com.packagename.yourapp?referrerId=<referrer>
.
When a user clicks an advertising link and starts installing the app, RuStore stores the referrer value from this link. The SDK then contacts RuStore, retrieves the referrer, and passes it to your app in the InstallReferrer parameter. This way, the application knows that an installation happened after following a particular advertising link.
Once RuStore passes the referrer value to the SDK, that value is removed from RuStore. Even if the SDK never requests the referrer, it is kept in RuStore for only 10 days before being deleted.
Implementation
Adding repository
repositories {
maven {
url = uri("https://artifactory-external.vkpartner.ru/artifactory/maven")
}
}
Connecting dependencies
dependencies {
implementation("ru.rustore.sdk:installreferrer:7.0.0")
}
Creating InstallReferrerClient
To work with referrer, create an InstallReferrerClient
using the class constructor
val client = InstallReferrerClient(context)
Getting InstallReferrer object
Call getInstallReferrer()
to get InstallReferrer
:
client.getInstallReferrer().addOnCompleteListener(object : OnCompleteListener<InstallReferrer> {
override fun onFailure(throwable: Throwable) {
// Handle error
}
override fun onSuccess(result: InstallReferrer) {
// Save InstallReferrer
}
})
-
In the
onSuccess
callback, store theInstallReferrer
value in your application if you plan to use it. On subsequent requests, RuStore will returnnull
instead ofInstallReferrer
.noteInstallReferrer
returnsnull
in the following cases:- The application was installed without a referrer parameter.
InstallReferrer
was already requested previously.- More than 10 days have passed since RuStore received the referrer.
-
In the
onFailure
callback, handle the error according to your app’s logic. All possible errors are listed below.
The Task class methods addOnCompletionListener()
, addOnSuccessListener()
, and addOnFailureListener()
allow you to catch various results:
addOnCompletionListener()
— triggers on both success and error outcomes.addOnSuccessListener()
— triggers only on a successful outcome.addOnFailureListener()
— triggers only on an error outcome.
For more details on these methods, see the Task API.
Errors
-
RuStoreNotInstalledException
— RuStore is not installed on the user's device. -
RuStoreOutdatedException
— RuStore version installed on the user's device does not support this SDK. -
RuStoreException
— basic RuStore error from which other errors are inherited.