Skip to main content

Native Ad Options

Ad Requset Timeout

Set timeout (seconds) for ad requests. GFPAdLoaderDelegate will call adLoader:didFailWithError:responseInfo: on timeout. Default is 60 seconds.

self.adLoader?.requestTimeoutInterval = ...

GFPNativeAdRenderingSetting

DFP adChoicesView Positions

DFP adChoiceView is located on the top right corner of the ad by default. Customize the location on one of the four corners by setting GFPNativeAdRenderingSetting.preferredAdChoicesViewPosition.

let renderingSetting = GFPNativeAdRenderingSetting()
renderingSetting.preferredAdChoicesViewPosition = .topRightCorner

let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = renderingSetting
info

Manually managing frame of DFP adChoiceView will now work as expected, despite the official guide.

Native Ad Without Media

Native ad without media content consists of only a icon image, title and body texts.

To exclude media view from a native noraml ad, set GFPNativeAdRenderingSetting.hasMediaView to NO.

danger

You should remove the media view as with hadMediaView set to NO. GFP SDK emits error if hasMediaView flag does not match the actual view hierarchy.

let setting = GFPNativeAdRenderingSetting()
setting.hasMediaView = false

let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = setting

Custom AdChoices Icon

AdChoices (or AdMute) icon or button is located on a corner of ad, providing users for options to hide unwanted ad.

The icon's appearance can be customized by setting GFPNativeAdRenderingSetting.adChociesCustomAsset

let customAsset = GFPCustomAsset(bundle: Bundle.main, size: CGSize(width: 42, height: 16), lightModeName: "commAd", darkModeName: "commAd_dark")

let setting = GFPNativeAdRenderingSetting()
setting.adChoicesCustomAsset = customAsset

let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = setting

Thumbnail for GFPMediaView

Set thumbnail on GFPMediaView to add natural feels to the ad before loading images. Thumbnail will be shown right after showPlaceholder, which automatically fits into GFPMediaView. The thumbnail will be removed by assigning GFPNativeAd instance to the GFPNativeAdView.

let nativeAdView = GFPNativeAdView()
self.addSubview(nativeAdView)
nativeAdView.frame = .init(x: 0, y: 0, width: 123, height: 123)
nativeAdView.mediaView?.showPlaceholder { imageView in
imageView.image = UIImage(named: "my_thumbnail")
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
}