Skip to main content

Banner Ad Options

GFPRenderDisplayAgentType

GFPRenderDisplayAgentType decides default behavior for landing on ad link. The default is GFPDisplayAgentTypeInApp

  • GFPDisplayAgentTypeInApp: opens in-app browser
  • GFPDisplayAgentTypeScheme: opens by app scheme
  • GFPDisplayAgentTypeNativeSafari: opens on safari
// Safari
let displayAgent = GFPRenderDisplayAgent(type: .displayAgentTypeNativeSafari)
GFPAdManager.adConfiguration().displayAgent = displayAgent

// App scheme
let displayAgent = GFPRenderDisplayAgent(type: .displayAgentTypeScheme, 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.

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 either adLoader:didReceiveNativeAd: or adLoader:didReceiveNativeSimpleAd: on ad response success.

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()

Configure GFPBannerViewLayoutType on GFPAdBannerOptions. Default is GFPBannerViewLayoutTypeFixed

info
  • In most cases, GFPBannerViewLayoutTypeFixed or GFPBannerViewLayoutTypeFluidWidth is recommended.

  • Innate banner size can be found in GFPBannerView.adSize

Fixed Layout

Banner content gets its size fixed regardless of its containing view.

let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = GFPBannerViewLayoutType(rawValue: 0)

Fluid Width Layout

You can set banner content's width manually.

let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluidWidth
  • Request ad with fluid width banner options, than configure width of the GFPBannerView by the desired size.
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
danger

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.

let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluidHeight

Fluid Layout

You can set banner content's width & height manually.

let bannerOption = GFPAdBannerOptions()
bannerOption.layoutType = .fluid

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.
//example
let bannerOption = GFPAdBannerOptions()
bannerOption.hostMeta = ["light":"theme"]
bannerOption.hostMeta = ["dark":"theme"]
bannerOption.hostMeta = ["system":"theme"]