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 500ms 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

Swift Package Manager

Following the steps defined in the integration section to install Nimbus using Swift Package Manager, include the package 'NimbusRequestAPSKit' in the selected packages.

CocoaPods

  1. Add the subspec NimbusRequestAPSKit for the NimbusSDK declaration into your project’s Podfile. pod 'NimbusSDK', subspecs: ['NimbusSDK', 'NimbusRequestAPSKit']

  2. Add the AmazonPublisherServicesSDK pod 'AmazonPublisherServicesSDK', '~> 4.6'

  3. Run pod install

Manual Installation

Drag NimbusRequestAPSKit.xcframework package into your project and make sure to select “Embed & Sign.”

Initialize the APS SDK

Be sure Nimbus is initialized before continuing with the APS integration.

Include all the line items that are setup with APS.

// Initialize APS SDK
DTBAds.sharedInstance().setAppKey(appKey)

// Set the MRAID Policy
DTBAds.sharedInstance().mraidCustomVersions = ["1.0", "2.0", "3.0"]
DTBAds.sharedInstance().mraidPolicy = CUSTOM_MRAID

// Set Nimbus as the Mediatior
DTBAds.sharedInstance().setAdNetworkInfo(.init(networkName: DTBADNETWORK_NIMBUS))

// Set Nimbus as the Open Measurement partner
DTBAds.sharedInstance().addCustomAttribute("omidPartnerName", value: Nimbus.shared.sdkName)
DTBAds.sharedInstance().addCustomAttribute("omidPartnerVersion", value: Nimbus.shared.version)

// Optional: Enable APS logging / test mode to verify the integration
DTBAds.sharedInstance().setLogLevel(DTBLogLevelAll)
DTBAds.sharedInstance().testMode = true

Adding an APS response and loader to a NimbusRequest

let loader = DTBAdLoader()
loader.setAdSizes([adSize])
loader.loadAd(self)

extension <YourClass>: DTBAdCallback {
        
        func onSuccess(_ adResponse: DTBAdResponse!) {
            // Add the APS bid to the Nimbus Request
            nimbusRequest.addApsResponse(response: adResponse)
            
            // If the Nimbus Request is for a refreshing banner
            nimbusRequest.addApsLoader(loader)

            // Send request to Nimbus
            nimbusAdManager.showAd(...)
        }
        
        func onFailure(_ error: DTBAdError) {
            // If the Nimbus Request is for a refreshing banner
            nimbusRequest.addApsLoader(loader)

            // Send request to Nimbus
            nimbusAdManager.showAd(...)
        }
    }
}

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

Last updated