APS

In this article, you will learn how to use Nimbus to request and render ads using Amazon Publisher Services SDK.

To include APS in a Nimbus auction, the APS SDK must be used to load an ad prior to making the request to Nimbus. The guide below will demonstrate how to initialize the APS SDK and append the responses to the Nimbus Request before sending the request to Nimbus.

How it works

After successfully loading an ad from APS SDK, you will pass the APS's response and ad loader to Nimbus SDK. After this step, Nimbus will be able to automatically get necessary key-value parameters from APS's response and inject them into the outbound request to Nimbus.

The APS Request is executed synchronously with a 600ms timeout, so in some cases with a slow internet connection, it may increase Nimbus' time to finish an auction.

Account Setup

Before integrating your app with Nimbus, you must set up your APS account with Amazon. Please follow the steps in the SDK Integration section of Amazon's documentation before proceeding.

Once you have your App ID (from Step 4.1) and SlotUUIDs (from Step 4.2) you can start integrating your App with Nimbus.

Installation

Include the APS SDK and Nimbus APS Extension.

dependencies {
    implementation("com.adsbynimbus.android:extension-aps:2.+")
    implementation("com.amazon.android:aps-sdk:9.8.+")
}

Initialize the APS SDK

/* Initialize APS SDK */
AdRegistration.getInstance(BuildConfig.APS_APP_KEY, applicationContext)

/* Set the MRAID Policy */
AdRegistration.setMRAIDSupportedVersions(arrayOf("1.0", "2.0", "3.0"))
AdRegistration.setMRAIDPolicy(MRAIDPolicy.CUSTOM)

/* Set Nimbus as the Mediator */
AdRegistration.setAdNetworkInfo(DTBAdNetworkInfo(DTBAdNetwork.NIMBUS))

/* Set Nimbus as the Open Measurement partner */
AdRegistration.addCustomAttribute("omidPartnerName", Nimbus.sdkName)
AdRegistration.addCustomAttribute("omidPartnerVersion", Nimbus.version)

/* Optional: Enable APS logging / test mode to verify the integration */
AdRegistration.enableLogging(true)
AdRegistration.enableTesting(true)

Adding an APS response to a NimbusRequest

val apsListener = object : DTBAdCallback {
    
    /* No bid from APS or some other error occurred */
    override fun onFailure(error: AdError) {
        
        /* If the Nimbus Request is for a refreshing banner */
        nimbusRequest.addApsLoader(response.adLoader)
        
        /* Send request to Nimbus */
        nimbusAdManager.showAd(...)
    }
 
    override fun onSuccess(response: DTBAdResponse) {
        /* Add the APS bid to the Nimbus Request */
        nimbusRequest.addApsResponse(response)
        
        /* If the Nimbus Request is for a refreshing banner */
        nimbusRequest.addApsLoader(response.adLoader)
        
        /* Send request to Nimbus */
        nimbusAdManager.showAd(...)
    }
 }
 val apsRequest = DTBAdRequest()
 apsRequest.setSizes(DTBAdSize(...)) // APS only accepts a single size
 apsRequest.loadAd(apsListener)

After completing the steps above, your app will be ready to show APS Ads just by calling nimbusAdManager.showAd(...).

Last updated