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
- Swift
- Objective-C
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.shared.prebidServerAccountId = @"accountId 입력";
//testAccountId: "bfa84af2-bd16-4d35-96ad-31c6bb888df0"
BannerAdUnit *bannerAdUnit = [[BannerAdUnit alloc] initWithConfigId:@"configId 입력" size:CGSizeMake(300, 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.
- Swift
- Objective-C
let requestPrebid = NSMutableDictionary.init()
bannerAdUnit.fetchDemand(adObject: requestPrebid) { (resultCode) in
if resultCode == ResultCode.prebidDemandFetchSuccess {
//TODO: Set adParam and request banner ad
}
}
NSMutableDictionary *requestPrebid = [NSMutableDictionary dictionary];
[bannerAdUnit fetchDemandWithAdObject:requestPrebid completion:^(enum ResultCode result) {
if(result == ResultCodePrebidDemandFetchSuccess) {
//TODO: Set adParam and request banner ad
}
}];
AdParam Settings & Banner Loading
- Set the Dictionary data obtained in step 2 to
prebidHBParamof AdParam. - Set the AdParam in GFPAdLoader or GFPBannerView, then request an ad.
- For more details on AdParam, refer to the Ad Request Parameters guide.
- Swift
- Objective-C
let adParam = GFPAdParam()
adParam.gender = .female
adParam.yearOfBirth = 1995
if let prebidParam = requestPrebid as? [String : String] {
adParam.prebidHBParam = prebidParam
}
//TODO: Request ad
GFPAdParam *adParam = [[GFPAdParam alloc] init];
adParam.gender = GFPAdParamGenderTypeFemale;
adParam.yearOfBirth = 1995;
adParam.prebidHBParam = requestPrebid;
//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.
- Swift
- Objective-C
DTBAds.sharedInstance().setAppKey("appKey 입력")
//testAppKey: "c5f20fe6e37146b08749d09bb2b6a4dd"
DTBAds.sharedInstance().mraidPolicy = CUSTOM_MRAID
DTBAds.sharedInstance().mraidCustomVersions = ["1.0", "2.0", "3.0"]
[[DTBAds sharedInstance] setAppKey: @"appKey 입력"];
//testAppKey: "c5f20fe6e37146b08749d09bb2b6a4dd"
[[DTBAds sharedInstance] setMraidPolicy:CUSTOM_MRAID];
[[DTBAds sharedInstance] setMraidCustomVersions:@[@"1.0", @"2.0", @"3.0"]];
APS Information Request
For more details, refer to the APS official guide.
- Swift
- Objective-C
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**/
}
DTBAdSize *dtbAdSize = [[DTBAdSize alloc] initBannerAdSizeWithWidth:320 height:50 andSlotUUID:@"slotUUID 입력"];
//testSlotUUID: "88e6293b-0bf0-43fc-947b-925babe7bf3f"
DTBAdLoader *adLoader = [DTBAdLoader new];
[adLoader setSizes:dtbAdSize, nil];
[adLoader loadAd:self];
#pragma mark - DTBAdCallback
- (void)onFailure: (DTBAdError)error {
NSLog(@"Failed to load ad :(");
/**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**/
}
- (void)onSuccess: (DTBAdResponse *)adResponse {
/**Build the ad request to your ad server. This portion will differ depending on your
ad server**/
}
AdParam Settings & Banner Loading
- When
onSuccessis received from DTBAdCallback, set the APS information inGFPAPSAdParam, then assign it toapsParamof AdParam. - Set the AdParam in GFPBannerView, then request an ad.
- (Note) [Reset previous data before requesting an ad] If reusing AdParam, you must reset
apsParamof AdParam whenonFailureis received.
- (Note) [Reset previous data before requesting an ad] If reusing AdParam, you must reset
- Swift
- Objective-C
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
}
- (void)onSuccess: (DTBAdResponse *)adResponse {
GFPAdParam *adParam = [[GFPAdParam alloc] init];
adParam.gender = GFPAdParamGenderTypeFemale;
adParam.yearOfBirth = 1995;
GFPAPSAdParam *apsParam = [[GFPAPSAdParam alloc] init];
apsParam.crid = adResponse.crid;
apsParam.size = CGSizeMake(adResponse.adSize.width, adResponse.adSize.height);
apsParam.apsHBParam = adResponse.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.
- Swift
- Objective-C
func bannerShouldUnload(_ bannerView: GFPBannerView) {
// ...
}
- (void)bannerShouldUnload:(GFPBannerView *)bannerView{
// ...
}