Skip to main content

Header Bidding

Header bidding is a system where programmatic bids are collected from the publisher's app and sent to the NAM server for ad requests. The NAM SDK supports header bidding for banner ads through the APS (Amazon Publisher Services) module.

While using header bidding may result in longer ad load times, it allows for serving higher-priced ads, maximizing revenue.

Add the APS SDK

Add the dependency for the APS mediation module to the app-level build.gradle.

info

To use header bidding through the APS module, please contact the NAM administrator.

info

If you explicitly set the version of the APS mediation dependency, note that the APS SDK version compatible with the NAM SDK is version 9.8.8 or higher.

dependencies {
implementation("com.naver.gfpsdk.mediation:nam-aps:<latest-version>")
}

Initializing the APS SDK

To use the APS SDK, you need to initialize it in Application.onCreate() as shown below.

class SampleApplication : Application() {
override fun onCreate() {
super.onCreate()

...
AdRegistration.getInstance("YOUR_APS_APP_KEY", this)
AdRegistration.setMRAIDSupportedVersions(arrayOf("1.0", "2.0", "3.0"))
AdRegistration.setMRAIDPolicy(MRAIDPolicy.CUSTOM)
}
}

Load a Banner Ads

To integrate APS banner ads into the NAM SDK, you must first load the APS banner ads. Before loading NAM banner ads, if the APS banner ads are successfully loaded, the DTBAdResponse object received should be added to the AdParam and then GfpBannerAdView.loadAd() should be called. If loading fails, GfpBannerAdView.loadAd() should be called without passing the DTBAdResponse object.

class ExampleActivity : AppCompatActivity() {
private lateinit var bannerAdView: GfpBannerAdView

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_example)

// The view container of banner ad view
val bannerAdContainer = findViewById(R.id.banner_ad_container)

// Create a new ad parameter
val adParam = AdParam.Builder()
.setAdUnitId("YOUR_AD_UNIT_ID")
.build()

// Create a new banner ad view
bannerAdView = GfpBannerAdView(this, adParam)

// Add the banner ad view to the view container
bannerAdContainer.addView(bannerAdView)

...

val dtbAdRequest = DTBAdRequest()
dtbAdRequest.sizes = DTBAdSize(320, 100, "YOUR_UUID")
dtbAdRequest.loadAd(object: DTBAdCallback {
override fun onFailure(adError: AdError) {
bannerAdView.loadAd()
}

override fun onSuccess(dtbAdResponse: DTBAdResponse) {
val adSizes = dtbAdResponse.dtbAds
if (adSizes != null && adSizes.isNotEmpty()) {
val apsAdParam = ApsUtils.createGfpApsAdParam(dtbAdResponse)
adParam.apsParam = apsAdParam
}
bannerAdView.loadAd()
}
})
}

override fun onDestroy() {
bannerAdView.destroy()
super.onDestroy()
}
}
caution

When reusing a single AdParam object to request APS ads multiple times, you must call the AdParam.buildUpon().setApsParam(null) method right before the request to create a new AdParam object. This ensures that the GfpApsAdParam value in the previously set AdParam is reset.

info

After loading APS banner ads using DtbAdRequest.loadAd(), you must pass the GfpApsAdParam object to the AdParam when the onSuccess() callback is delivered. If the onFailure() callback is delivered, you should proceed without passing the GfpApsAdParam object.


Testing the APS SDK

When enabling test mode for the APS SDK, you can receive test ads. The following example demonstrates how to enable test mode.

caution

Test mode must be disabled in the release build.

class SampleApplication : Application() {
override fun onCreate() {
super.onCreate()

...
AdRegistration.enableTesting(true)
AdRegistration.enableLogging( true )
}
}

APS Guide

For detailed instructions on using APS, please refer to the APS Android Guide. You will need to log in with your Amazon account.