Skip to main content

Header Bidding

Header Bidding

Header bidding is supported through PrebidMobile and Amazon Publisher Services (referred to as "APS").

PrebidMobile has been verified based on version 1.5. APS has been verified with sample development and QA testing completed based on version 3.4.6 provided by Amazon. Please refer accordingly.

source 'https://github.com/CocoaPods/Specs.git'

target 'MyApplication' do
pod 'PrebidMobile', '1.5'
pod 'AmazonPublisherServicesSDK', '3.4.6'
end

PrebidMobile Integration

Header bidding integration via PrebidMobile is supported for banner ads only.

The guide below covers content related to NAMSDK integration. For more details on PrebidMobile, please refer to the official guide.

Prebid Settings

Prebid.shared.prebidServerAccountId = @"accountId 입력";
//testAccountId: "bfa84af2-bd16-4d35-96ad-31c6bb888df0"

let bannerAdUnit = BannerAdUnit(configId: "configId 입력", size: CGSize(width: 300, height: 250))
//testConfigId: "6ace8c7d-88c0-4623-8117-75bc3f0a2e45"

Prebid Information Request

  • Call fetchDemandWithAdObject:completion: with NSMutableDictionary as a parameter.
  • On a successful fetch, data with the "hb_" prefix will be added to the created Dictionary.
let requestPrebid = NSMutableDictionary.init()

bannerAdUnit.fetchDemand(adObject: requestPrebid) { (resultCode) in
if resultCode == ResultCode.prebidDemandFetchSuccess {
//TODO: Set adParam and request banner ad
}
}

AdParam Settings & Banner Loading

  • Set the Dictionary data obtained in step 2 to prebidHBParam of AdParam.
  • Set the AdParam in GFPAdLoader or GFPBannerView, then request an ad.
  • For more details on AdParam, refer to the Ad Request Parameters guide.
let adParam = GFPAdParam()
adParam.gender = .female
adParam.yearOfBirth = 1995

if let prebidParam = requestPrebid as? [String : String] {
adParam.prebidHBParam = prebidParam
}

//TODO: Request ad

APS Integration

Header bidding integration via APS is supported for banner ads only.

The guide below covers content related to NAMSDK integration. For more details on APS, please refer to the official guide.

APS Settings

NAMSDK supports MRAID 1.0, 2.0, and 3.0 specs. Please make sure to follow the MRAID settings below.

DTBAds.sharedInstance().setAppKey("appKey 입력")
//testAppKey: "c5f20fe6e37146b08749d09bb2b6a4dd"

DTBAds.sharedInstance().mraidPolicy = CUSTOM_MRAID
DTBAds.sharedInstance().mraidCustomVersions = ["1.0", "2.0", "3.0"]

APS Information Request

For more details, refer to the APS official guide.

let dtbAdSize = DTBAdSize(bannerAdSizeWithWidth: 320, height: 50, andSlotUUID: "slotUUID 입력")
//testSlotUUID: "88e6293b-0bf0-43fc-947b-925babe7bf3f"

let dtbAdLoader = DTBAdLoader()
dtbAdLoader.setAdSizes([dtbAdSize])
dtbAdLoader.loadAd(self)
func onFailure(_ error: DTBAdError) {
/**Please implement the logic to send ad request without our parameters if you want to
show ads from other ad networks when Amazon ad request fails**/
}

func onSuccess(_ adResponse: DTBAdResponse!) {
/**Build the ad request to your ad server. This portion will differ depending on your
ad server**/
}

AdParam Settings & Banner Loading

  • When onSuccess is received from DTBAdCallback, set the APS information in GFPAPSAdParam, then assign it to apsParam of AdParam.
  • Set the AdParam in GFPBannerView, then request an ad.
    • (Note) [Reset previous data before requesting an ad] If reusing AdParam, you must reset apsParam of AdParam when onFailure is received.
func onSuccess(_ adResponse: DTBAdResponse!) {
let adParam = GFPAdParam()
adParam.gender = .female
adParam.yearOfBirth = 1995

let apsParam = GFPAPSAdParam()
apsParam.crid = adResponse.crid
apsParam.size = CGSize(width: adResponse.adSize.width, height: adResponse.adSize.height)

if let customTargeting = adResponse.customTargeting().map as? [String : NSObject] {
apsParam.apsHBParam = customTargeting
}

apsParam.skAdNetworkParams = adResponse.skAdNetworkParams;

adParam.apsParam = apsParam;

//TODO: Request banner ad
}

MRAID 3.0 Unload

The following method has been added to GFPBannerViewDelegate to notify events that occur when Unload is called in MRAID 3.0.

func bannerShouldUnload(_ bannerView: GFPBannerView) {
// ...
}