Native Ad Options
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 = ...
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
.
- Swift
- Objective-C
let renderingSetting = GFPNativeAdRenderingSetting()
renderingSetting.preferredAdChoicesViewPosition = .topRightCorner
let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = renderingSetting
GFPNativeAdRenderingSetting *setting = [GFPNativeAdRenderingSetting alloc] init];
setting.preferredAdChoicesViewPosition = GFPAdChoicesViewPositionTopRightCorner;
GFPAdNativeOptions *nativeOptions = [[GFPAdNativeOptions alloc] init];
nativeOptions.renderingSetting = setting;
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
.
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.
- Swift
- Objective-C
let setting = GFPNativeAdRenderingSetting()
setting.hasMediaView = false
let nativeOption = GFPAdNativeOptions()
nativeOption.renderingSetting = setting
GFPNativeAdRenderingSetting *setting = [GFPNativeAdRenderingSetting alloc] init];
setting.hasMediaView = NO;
GFPAdNativeOptions *nativeOptions = [[GFPAdNativeOptions alloc] init];
nativeOptions.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
- Swift
- Objective-C
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
GFPCustomAsset *customAsset = [[GFPCustomAsset alloc] initWith:[NSBundle mainBundle] size:CGSizeMake(44, 16) lightModeName:@"commAd" darkModeName:@"commAd_dark"];
GFPNativeAdRenderingSetting *setting = [GFPNativeAdRenderingSetting alloc] init];
setting.adChoicesCustomAsset = customAsset;
GFPAdNativeOptions *nativeOptions = [[GFPAdNativeOptions alloc] init];
nativeOptions.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.
- Swift
- Objective-C
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
}
GFPNativeAdView *nativeAdView = [[GFPNativeAdView alloc] init];
[self addSubview:nativeAdView];
nativeAdView.frame = CGRectMake(0, 0, 123, 123);
[nativeAdView.mediaView showPlaceholder:^(UIImageView *imageView) {
imageView.image = [UIImage imageNamed:@"my_thumbnail"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
}];