Header bidding application guide
Header Bidding
HeaderBidding is supported through PrebidMobile and Amazon Publisher Services (APS). PrebidMobile was confirmed based on version 1.5. Please note that APS completed the sample development and QA verification based on version 3.4.6 provided by Amazon.
The guide below covers content related to GFPSDK integration. For more information about PrebidMobile, please refer to the official guide.
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 through PrebidMobile is supported only for banner ads with GFPSDK version 1.4.0 or higher.
The guide below covers content related to GFPSDK integration. For more information about PrebidMobile, please refer to the official guide
Prebid Settings
- Objective-C
- Swift
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.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.
- When the fetch is successful, data with the prefix “hb_“ will be added to the created Dictionary.
- Objective-C
- Swift
NSMutableDictionary *requestPrebid = [NSMutableDictionary dictionary];
[bannerAdUnit fetchDemandWithAdObject:requestPrebid completion:^(enum ResultCode result) {
if(result == ResultCodePrebidDemandFetchSuccess) {
//TODO: load banner ad
}
}];
let requestPrebid = NSMutableDictionary.init()
bannerAdUnit.fetchDemand(adObject: requestPrebid) { (resultCode) in
if resultCode == ResultCode.prebidDemandFetchSuccess {
//TODO: load banner ad
}
}
AdParam Settings & Banner Loading
- Set the Dictionary data obtained in step 2 to the prebidHBParam of AdParam.
- Set the AdParam in GFPAdLoader or GFPBannerView, and request an advertisement.
- For more information about AdParam, please refer to the Ad request information guide.
- Objective-C
- Swift
GFPAdParam *adParam = [[GFPAdParam alloc] init];
adParam.gender = GFPAdParamGenderTypeFemale;
adParam.yearOfBirth = 1995;
adParam.prebidHBParam = requestPrebid;
//TODO: load ad
let adParam = GFPAdParam()
adParam.gender = .female
adParam.yearOfBirth = 1995
if let prebidParam = requestPrebid as? [String : String] {
adParam.prebidHBParam = prebidParam
}
//TODO: load ad
APS Integration
GFPSDK 2.0.0-6.x.x | Only supported in banner ads
GFPSDK >=7.0.0 | Only supported in banner and rewarded ads (interstitial ad is not supported).
The guide below covers content related to GFPSDK integration. For more information about APS please refer to the official guide
APS Settings
MRAID 1.0, 2.0, and 3.0 specifications are supported in GFPSDK. Make sure to follow the MRAID settings below.
- Objective-C
- Swift
[[DTBAds sharedInstance] setAppKey: @"appKey"];
//testAppKey: "c5f20fe6e37146b08749d09bb2b6a4dd"
[[DTBAds sharedInstance] setMraidPolicy:CUSTOM_MRAID];
[[DTBAds sharedInstance] setMraidCustomVersions:@[@"1.0", @"2.0", @"3.0"]];
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 information, please refer to the APS official guide
- Objective-C
- Swift
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**/
}
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 Setting & Banner Loading
- When onSuccess was received for DTBAdCallback, set the APS information in GFPAPSAdParam and then set it up in apsParam of AdParam.
- Set AdParam on each ad type call and then send an ad request.
For each advertisement call, a new DTBAdResponse must be downloaded and set to GFPAdParam.GFPApsAdParam. When a DTBAdResponse is reused, the identical advertising materials may be exposed repeatedly.
- Objective-C
- Swift
- (void)onSuccess: (DTBAdResponse *)adResponse {
GFPAdParam *adParam = [[GFPAdParam alloc] init];
adParam.gender = GFPAdParamGenderTypeFemale;
adParam.yearOfBirth = 1995;
GFPAPSAdParam *apsParam = [[GFPAPSAdParam alloc] init];
apsParam.crid = adResponse.crid; // required
apsParam.size = CGSizeMake(adResponse.adSize.width, adResponse.adSize.height); // required
apsParam.mediationHints = adResponse.mediationHints(); // required for GFPSDK >=7.0.0
apsParam.apsHBParam = adResponse.customTargeting;
apsParam.skAdNetworkParams = adResponse.skAdNetworkParams;
adParam.apsParam = apsParam;
//TODO: Load Ad
}
func onSuccess(_ adResponse: DTBAdResponse!) {
let adParam = GFPAdParam()
adParam.gender = .female
adParam.yearOfBirth = 1995
let apsParam = GFPAPSAdParam()
apsParam.crid = adResponse.crid // required
apsParam.size = CGSize(width: adResponse.adSize.width, height: adResponse.adSize.height) // required
apsParam.mediationHints = adResponse.mediationHints() // required for GFPSDK >=7.0.0
apsParam.apsHBParam = adResponse.customTargeting
apsParam.skAdNetworkParams = adResponse.skAdNetworkParams
if let customTargeting = adResponse.customTargeting().map as? [String : NSObject] {
apsParam.apsHBParam = customTargeting
}
adParam.apsParam = apsParam;
//TODO: Load 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.
- Objective-C
- Swift
- (void)bannerShouldUnload:(GFPBannerView *)bannerView{
// ...
}
func bannerShouldUnload(_ bannerView: GFPBannerView) {
// ...
}