Guides
Guides

Android SDK

Instructions for integrating Lootably's Android SDK into your Android application

The Lootably Android SDK is a lightweight SDK that provides a native offerwall experience for Android apps. If you do not already have a Lootably Publisher Account, follow the instructions in this article to apply for an account.

Install the SDK

Download the SDK aar file and place it into your app's libs/ directory.

Then, add the dependencies to your build.gradle file

dependencies {
    implementation(files("libs/lootably-sdk-1.0.aar"))
  
    # Required by Lootably SDK
    api("io.socket:socket.io-client:2.0.1") {
        exclude(group = "org.json", module = "json")
    }
}

Use the SDK

Initializing

Inside of your app's code, you must first initialize the SDK:

// Import SDK
import com.lootably.sdk.LootablyOfferwallSDK

// Initialize the Lootably SDK
val lootablySDK = LootablyOfferwallSDK.initialize(
  placementID = "YOUR_PLACEMENT_ID",
  sid = "USERID"
)

The sid value passed into the Lootably SDK must be unique for each user. If your app does not require users to sign in, we would recommend passing the user's Advertising ID.

Opening the offerwall

Once the SDK is initialized, you can open the offerwall by calling openOfferwall:

lootablySDK.openOfferwall(this)

Listening for conversions

We recommend all publishers implement server-side Postback requests if possible, as they are much safer. However, if your app does not require users to sign in or if your currency is entirely client-side, you should use the event listener detailed below to award currency to users.

// Implementation of CurrencyEarnedListener
override fun onCurrencyEarned(offerData: CurrencyEarnedListener.OfferCompletionData) {
  // Log the currency earned callback
  android.util.Log.d("MainActivity", "Currency earned - Transaction ID: ${offerData.transactionID}, Reward: ${offerData.currencyReward}")
}

For reference, this is the full OfferCompletionData type:

data class OfferCompletionData(
  val offerID: String,
  val offerName: String, 
  val currencyReward: Float,
  val transactionID: String
)

onCurrencyEarned will be called at two distinct times in the lifecycle of the SDK:

  • When the SDK is first initialized, we will trigger onCurrencyEarned for each conversion processed while the user was offline.
  • If the SDK is initialized, we will trigger onCurrencyEarned each time a conversion is processed, including when the offerwall is open.