Banner Ad Options
GFPRenderDisplayAgentType
GFPRenderDisplayAgentType
decides default behavior for landing on ad link. The default is GFPDisplayAgentTypeInApp
GFPDisplayAgentTypeInApp
: opens in-app browserGFPDisplayAgentTypeScheme
: opens by app schemeGFPDisplayAgentTypeNativeSafari
: opens on safari
- Swift
- Objective-C
// Safari
let displayAgent = GFPRenderDisplayAgent(type: .displayAgentTypeNativeSafari)
GFPAdManager.adConfiguration().displayAgent = displayAgent
// App scheme
let displayAgent = GFPRenderDisplayAgent(type: .displayAgentTypeScheme, scheme: "AppScheme")
GFPAdManager.adConfiguration().displayAgent = displayAgent
// Safari
GFPRenderDisplayAgent *displayAgent = [[GFPRenderDisplayAgent alloc] initWithType: GFPDisplayAgentTypeNativeSafari];
[GFPAdManager adConfiguration].displayAgent = displayAgent;
// App scheme
GFPRenderDisplayAgent *displayAgent = [[GFPRenderDisplayAgent alloc] initWithType: GFPDisplayAgentTypeScheme scheme: @"AppScheme"];
[GFPAdManager adConfiguration].displayAgent = displayAgent;
Ad Requset Timeout
Set timeout (seconds) for ad requests. GFPAdLoaderDelegate
will call adLoader:didFailWithError:responseInfo:
on timeout. Default is 60 seconds.
- Swift
- Objective-C
self.adLoader?.requestTimeoutInterval = ...
self.adLoader.requestTimeoutInterval = ...
Loading Native Ad Simultaneously
Load either banner or native ad on single ad request.
-
Configure native ad request options along with banner ad on single
GFPAdLoader
as in code example. -
GFPAdLoaderDelegate
will call eitheradLoader:didReceiveNativeAd:
oradLoader:didReceiveNativeSimpleAd:
on ad response success.
- Swift
- Objective-C
let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = ...
self.adLoader?.setNativeDelegate(self, nativeOptions: nativeOption)
let nativeSimpleOption = GFPAdNativeSimpleOptions()
nativeSimpleOption.simpleAdRenderingSetting = ...
self.adLoader?.setNativeSimpleDelegate(self, nativeSimpleOptions: nativeSimpleOption)
self.adLoader?.delegate = self
self.adLoader?.loadAd()
GFPAdNativeOptions *nativeOptions = [[GFPAdNativeOptions alloc] init];
nativeOptions.renderingSetting = ...;
[self.adLoader setNativeDelegate:self nativeOptions:nativeOptions];
GFPAdNativeSimpleOptions *nativeSimpleOptions = [[GFPAdNativeSimpleOptions alloc] init];
nativeSimpleOptions.simpleAdRenderingSetting = ...;
[self.adLoader setNativeSimpleDelegate:self nativeSimpleOptions:nativeSimpleOptions];
self.adLoader.delegate = self;
[self.adLoader loadAd];
Banner Layout Type
Configure GFPBannerViewLayoutType
on GFPAdBannerOptions
. Default is GFPBannerViewLayoutTypeFixed
-
In most cases,
GFPBannerViewLayoutTypeFixed
orGFPBannerViewLayoutTypeFluidWidth
is recommended. -
Innate banner size can be found in
GFPBannerView.adSize
Fixed Layout
Banner content gets its size fixed regardless of its containing view.
- Swift
- Objective-C
let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = GFPBannerViewLayoutType(rawValue: 0)
GFPAdBannerOptions *bannerOptions = [[GFPAdBannerOptions alloc] init];
bannerOptions.layoutType = GFPBannerViewLayoutTypeFixed;
Fluid Width Layout
You can set banner content's width manually.
- Swift
- Objective-C
let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluidWidth
GFPAdBannerOptions *bannerOptions = [[GFPAdBannerOptions alloc] init];
bannerOptions.layoutType = GFPBannerViewLayoutTypeFluidWidth;
- Request ad with fluid width banner options, than configure width of the
GFPBannerView
by the desired size.
- Swift
- Objective-C
self.bannerView?.translatesAutoresizingMaskIntoConstraints = false
self.bannerView?.widthAnchor.constraint(equalToConstant: SUPERVIEW_SIZE.width).isActive = true
let frame = CGRect(x: x, y: y, width: width, height: height)
self.bannerView?.frame = frame
self.bannerView.translatesAutoresizingMaskIntoConstraints = NO;
[self.bannerView.widthAnchor constraintEqualToConstant:SUPERVIEW_SIZE.width].active = YES;
CGRect frame = CGRectMake(x, y, width, height);
[self.bannerView setFrame: frame];
The received banner ad should innately support fluid width layout,
GFPBannerView will draw background on the sides if it doesn't.
Fluid Height Layout
You can set banner content's height manually.
- Swift
- Objective-C
let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluidHeight
GFPAdBannerOptions *bannerOptions = [[GFPAdBannerOptions alloc] init];
bannerOptions.layoutType = GFPBannerViewLayoutTypeFluidHeight;
Fluid Layout
You can set banner content's width & height manually.
- Swift
- Objective-C
let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluid
GFPAdBannerOptions *bannerOptions = [[GFPAdBannerOptions alloc] init];
bannerOptions.layoutType = GFPBannerViewLayoutTypeFluid;
Requesting with Host Meta Data
You can send hostMeta with ad request, which is data discussed between the publisher and advertiser.
- You can send device's interface style. It is prioritized over the global setting, interface style.
- Swift
- Objective-C
//example
let bannerOption = GFPAdBannerOptions()
bannerOption.hostMeta = ["light":"theme"]
bannerOption.hostMeta = ["dark":"theme"]
bannerOption.hostMeta = ["system":"theme"]
//example
GFPAdBannerOptions *bannerOptions = [[GFPAdBannerOptions alloc] init];
bannerOptions.hostMeta = [NSDictionary dictionaryWithObjectsAndKeys:@"light", @"theme", nil];
bannerOptions.hostMeta = [NSDictionary dictionaryWithObjectsAndKeys:@"dark", @"theme", nil];
bannerOptions.hostMeta = [NSDictionary dictionaryWithObjectsAndKeys:@"system", @"theme", nil];