Docs

Android SDK

Kotlin library for Android. Banner, interstitial, rewarded video — with HMAC-signed reward callbacks to your backend.

Install via Gradle

Add the dependency, register the rewarded activity in your manifest, and you're done.

build.gradle.kts
// settings.gradle.kts — make sure mavenCentral is on:
dependencyResolutionManagement {
    repositories {
        mavenCentral()
    }
}

// app/build.gradle.kts:
dependencies {
    implementation("to.mpwa.ads:mpwa-ads:0.1.0")
}
AndroidManifest.xml
<!-- AndroidManifest.xml — register the rewarded activity. -->
<application>
    <activity
        android:name="to.mpwa.ads.RewardedVideoAdActivity"
        android:screenOrientation="portrait"
        android:exported="false" />
</application>

Minimum minSdk 24 · Kotlin 2.0 · AGP 8.7.

Configure once in Application.onCreate

Static MpwaAds.configure() pre-warms the HTTP client and signing key so the first ad request is fast.

YourApplication.kt
import to.mpwa.ads.MpwaAds

class YourApplication : android.app.Application() {
    override fun onCreate() {
        super.onCreate()
        MpwaAds.configure(
            publisherId = "YOUR_PUBLISHER_ID",
            adServerUrl = "https://ads.mpwa.to"
        )
    }
}

Rewarded video — full flow

Two-step lifecycle: load() then show(activity). Reward fires only after the user watches past skip_after_sec; we POST a signed grant to your SSV endpoint in parallel.

RewardedFlow.kt
import to.mpwa.ads.RewardedVideoAd
import to.mpwa.ads.Reward
import kotlinx.coroutines.launch

class RewardedFlow(private val adUnitId: Long) {
    private val ad = RewardedVideoAd(adUnitId).apply {
        listener = object : RewardedVideoAd.Listener {
            override fun onRewarded(reward: Reward) {
                // Credit reward.amount of reward.currency. Server-side
                // verification fires in parallel to your SSV callback
                // (set in /dashboard/settings → Rewarded SSV).
                Log.d("mpwa", "granted ${reward.amount} ${reward.currency}")
            }
            override fun onAdDismissed() {
                Log.d("mpwa", "user closed without completing")
            }
        }
    }

    fun loadAndShow(activity: Activity, scope: CoroutineScope) {
        scope.launch {
            try {
                ad.load()
                ad.show(activity)
            } catch (e: Exception) {
                Log.w("mpwa", "rewarded load failed", e)
            }
        }
    }
}

Set the SSV callback URL on /dashboard/settings → Rewarded SSV before going live. Without it the SDK still grants, but you have no server-side signal to credit the user authoritatively.