Native Simple 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 = ...
Interface Style
Configure interface style to customize icon's appearance.
This setting overrides Global Interface Style Setting. Use this setting to alter the appearance in certain contexts.
- Swift
- Objective-C
let simpleRenderingSetting = GFPNativeSimpleAdRenderingSetting()
simpleRenderingSetting.adInterfaceStyle = .light
simpleRenderingSetting.adInterfaceStyle = .dark
simpleRenderingSetting.adInterfaceStyle = .system
let nativeSimpleOption = GFPAdNativeSimpleOptions()
nativeSimpleOption.simpleAdRenderingSetting = simpleRenderingSetting
GFPNativeAdRenderingSetting *simpleAdRenderingSetting = [[GFPNativeAdRenderingSetting alloc] init];
simpleAdRenderingSetting.adInterfaceStyle = GFPAdInterfaceStyleLight;
simpleAdRenderingSetting.adInterfaceStyle = GFPAdInterfaceStyleDark;
simpleAdRenderingSetting.adInterfaceStyle = GFPAdInterfaceStyleSystem;
GFPAdNativeSimpleOptions *nativeSimpleOptions = [[GFPAdNativeSimpleOptions alloc] init];
nativeSimpleOptions.simpleAdRenderingSetting = simpleAdRenderingSetting;
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 simpleRenderingSetting = GFPNativeSimpleAdRenderingSetting()
simpleRenderingSetting.adChoicesCustomAsset = customAsset
let nativeSimpleOption = GFPAdNativeSimpleOptions()
nativeSimpleOption.simpleAdRenderingSetting = simpleRenderingSetting
GFPCustomAsset *customAsset = [[GFPCustomAsset alloc] initWith:[NSBundle mainBundle] size:CGSizeMake(44, 16) lightModeName:@"commAd" darkModeName:@"commAd_dark"];
GFPNativeSimpleAdRenderingSetting *simpleRenderingSetting = [GFPNativeSimpleAdRenderingSetting alloc] init];
simpleRenderingSetting.adChoicesCustomAsset = customAsset;
GFPAdNativeSimpleOptions *nativeSimpleOptions = [[GFPAdNativeSimpleOptions alloc] init];
nativeSimpleOptions.simpleAdRenderingSetting = simpleAdRenderingSetting;
Lazy Loading for Native Simple Ads
Enabling Lazy Loading
Enable lazy loading on Native Simple ad's rendering settings to receive GFPNativeSimpleAd and text assets via
GFPAdLoaderDelegate.adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceive nativeSimpleAd: GFPNativeSimpleAd!).
Media view's asset will be loaded asynchronously.
- Swift
- Objective-C
self.adLoader = GFPAdLoader(unitID: "UnitId", rootViewController: self, adParam: adParam)
let nativeSimpleOption = GFPAdNativeSimpleOptions()
nativeSimpleOption.renderingSetting.useLazyMediaLoading = true
self.adLoader?.setNativeSimpleDelegate(self, nativeSimpleOptions: nativeSimpleOption)
self.adLoader?.delegate = self
self.adLoader?.loadAd()
self.adLoader = [[GFPAdLoader alloc] initWithUnitID:self.unitID
rootViewController:self
adParam:adParam];
GFPAdNativeSimpleOptions *nativeSimpleOptions = [[GFPAdNativeSimpleOptions alloc] init];
nativeSimpleOptions.renderingSetting.useLazyMediaLoading = YES;
[self.adLoader setNativeSimpleDelegate:self nativeSimpleOptions:nativeSimpleOptions];
// 광고 요청
self.adLoader.delegate = self;
[self.adLoader loadAd];
Showing Placeholder While Lazy Loading
Media views are able to show placeholder while lazy loading. Placeholders will are automatically fit to its parent media view's bounds.
- Swift
- Objective-C
func adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceive nativeAdSimpleAd: GFPNativeSimpleAd!) {
self.nativeSimpleAdView.nativeAd = nativeSimpleAd
self.nativeSimpleAdView.mediaView?.showPlaceholder { imageView in
imageView.image = UIImage(named: "my_media_placeholder")
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
}
- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didReceiveNativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd {
self.nativeSimpleAdView.nativeAd = nativeSimpleAd
[self.nativeSimpleAdView.mediaView showPlaceholderWith:^(UIImageView *imageView) {
imageView.image = [UIImage imageNamed:@"my_media_placeholder"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
}];
}
Async Media Loading Callbacks
On completing lazy loading all required media,
nativeSimpleAdDidLoadMedia(_:)
of
GFPNativeSimpleAdDelegate
will be called.
If any of the media asset fails to load,
nativeSimpleAdDidFail(toLoadMedia:)
will be called.
- Swift
- Objective-C
// GFPNativeSimpleAdDelegate
func nativeSimpleAdDidLoadMedia(_ nativeSimpleAd: GFPNativeSimpleAd) {
self.nativeSimpleAdView.removePlaceholders() // Optional for safety.
}
func nativeSimpleAdDidFail(toLoadMedia nativeSimpleAd: GFPNativeSimpleAd) {
// Example showing new placeholders on failure.
self.nativeSimpleAdView.mediaView?.showPlaceholder { imageView in
imageView.image = UIImage(named: "my_fallback_media_placeholder")
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
}
}
// GFPNativeSimpleAdDelegate
- (void)nativeSimpleAdDidLoadMedia:(GFPNativeSimpleAd *)nativeSimpleAd {
[self.nativeSimpleAdView removePlaceholders]; // Optional for safety.
}
- (void)nativeSimpleAdDidFailToLoadMedia:(GFPNativeSimpleAd *)nativeSimpleAd {
// Example showing new placeholders on failure.
[self.nativeSimpleAdView.mediaView showPlaceholderWith:^(UIImageView *imageView) {
imageView.image = [UIImage imageNamed:@"my_fallback_media_placeholder"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
imageView.clipsToBounds = YES;
}];
}