Dependencies
Add the Prebid Mobile SDK dependency to build.gradle (Module: app):
implementation 'org.prebid:prebid-mobile-sdk:3.3.1'
Configuration
Define constants for connecting to the IA.BOX server:
const val SERVER_URL = "https://ia.box/ads/prebid"
const val ACCOUNT_ID = "test" // Bundle ID
const val CONFIG_ID = "test_banner" // placement name
SDK Initialization
Called once at app startup (e.g. in onCreate of Application or Activity):
PrebidMobile.setPrebidServerAccountId(ACCOUNT_ID)
PrebidMobile.setTimeoutMillis(10000) // bidding timeout, ms
PrebidMobile.setShareGeoLocation(true) // pass geolocation
PrebidMobile.initializeSdk(applicationContext, SERVER_URL) { status ->
runOnUiThread {
if (status == InitializationStatus.SUCCEEDED) {
// SDK is ready
}
}
}
Resource cleanup
Call in onDestroy() of Activity or Fragment to avoid memory leaks:
override fun onDestroy() {
super.onDestroy()
bannerView?.destroy()
}
Do not forget to call destroy() for all created BannerView and InterstitialAdUnit instances.