Skip to main content

Native Simple Ads

Native Simple ads contain single native view that conatins an image or enriched contents as content.

Implementing View Controller

In the view controller that will present the ad view as subview,

  • add these properties

    GFPAdLoader *adLoader

    GFPNativeSimpleAd *bannerView

  • and implement these delegate protocols

    GFPAdLoaderDelegate

    GFPNativeSimpleAdDelegate

// MyViewController.h

@import GFPSDK;

@interface MyViewController : UIViewController <GFPAdLoaderDelegate, GFPNativeSimpleAdDelegate>

@property (nonatomic) GFPAdLoader *adLoader;

@property (nonatomic) GFPNativeSimpleAd *nativeSimpleAd;
@property (nonatomic) GFPNativeSimpleAdView *nativeSimpleAdView;

@end

GFPAdLoader

Initialize GFPAdLoader in your view controller, say, in viewDidLoad: and request an ad.

  • Provider GFPAdLoader with Ad Unit ID (essential) as registered on GFP dashboard, and GFPAdParam (optional) for better ad performance.

  • Set GFPAdLoaderDelegate on GFPAdLoader.

danger

Do not use GFPAdLoader instance for multiple ad requests, since it's only designed for single ad request.

- (void)viewDidLoad {
[super viewDidLoad];

GFPAdParam *adParam = [[GFPAdParam alloc]init];
adParam.yearOfBirth = 1990;
adParam.gender = GFPAdParamGenderTypeMale;
...

self.adLoader = [[GFPAdLoader alloc] initWithUnitID:self.unitID
rootViewController:self
adParam:adParam];

GFPAdNativeSimpleOptions *nativeSimpleOptions = [[GFPAdNativeSimpleOptions alloc] init];
nativeSimpleOptions.simpleAdRenderingSetting = ...;
[self.adLoader setNativeSimpleDelegate:self nativeSimpleOptions:nativeSimpleOptions];

self.adLoader.delegate = self;
[self.adLoader loadAd];
}

Additional Configurations

Ad Requset Timeout

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

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.

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

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;
Custom Background
GFPNativeSimpleAdRenderingSetting *renderingSetting = [[GFPNativeSimpleAdRenderingSetting alloc] init];

//for naverApp's backColor
GFPAdBackgroundInfo *backgroundInfo = [[GFPAdBackgroundInfo alloc] initWithBackground:[UIColor colorWithRGBIntWith:0xF4F5F6] alpha:0.65 left:8 right:8 top:0 bottom:0 cornerRadius:10];

renderingSetting.adBackgroundInfo = backgroundInfo;
nativeSimpleOptions.simpleAdRenderingSetting = renderingSetting;

Premium Video Ad Delegate

GFPNativeVideoEventDelegate handles AVPlayer in Native Simple ads that conatins videos (NS Rich Video Ads).


GFPNativeSimpleAdRenderingSetting *renderingSetting = [[GFPNativeSimpleAdRenderingSetting alloc] init];
nativeSimpleOptions.renderingSetting.videoEventDelegate = ...;

GFPNativeVideoEventDelegate
  • On Video Will Play. It is called before AVPlayer play:

    - (void)nativeAd:(NSObject *)nativeAd richVideoWillPlayWith:(BOOL)isMuted;
  • On Video Did Play. It is called after AVPlayer play:

    - (void)nativeAd:(NSObject *)nativeAd richVideoDidPlayWith:(BOOL)isMuted;
  • On Video Will Pause. It is called before AVPlayer pause:

    It does not include situations where video being stopped due to deallocation or errors.

    - (void)nativeAd:(NSObject *)nativeAd richVideoWillStopWith:(BOOL)isMuted;
  • On Video Will Pause. It is called after AVPlayer pause: and status being updated.

    It includes situation where video being stopped due to deallocation.

    - (void)nativeAd:(NSObject *)nativeAd richVideoDidStopWith:(BOOL)isMuted;
  • On IsMute Changed.

    - (void)nativeAd:(NSObject *)nativeAd richVideoMuteChanged:(BOOL)isMuted;

Implementing Interface Builder

GFPNativeAd\ requires to be subclassed by an interface builder view. Create an .xib file with a view and subclass GFPNativeSimpleAdView and its subviews.

  1. In your .xib file, open Identity Inspector tab on Xcode, than set Custom Class to GFPNativeSimpleAdView. 예시이미지

  2. Add subviews that corresponds to title label, body label, etc. onto the GFPNativeSimpleAdView and connect them to outlets on the Connections Inspector tab.

  3. Add a view and set outlet for GFPNativeBaseView.mediaView 예시이미지

danger

Do not allocate more than one GFPNativeSimpleAdView for one GFPNativeAd.

GFPAdLoaderDelegate

On Ad Load Success

- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didReceiveNativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd {
// Get estimated ad height
CGFloat estimateHeight = [nativeSimpleAd estimateHeightWith: self.nativeSimpleAdView.bounds.size.width];

// Set `GFPNativeSimpleAdDelegate`
self.nativeSimpleAd = nativeSimpleAd;
self.nativeSimpleAd.delegate = self;

// As soon as assigning a `GFPNativeSimpleAd` to the `GFPNativeSimpleAdView`, it starts tracking impressions, and rendering iconView and mediaView images.
self.nativeSimpleAdView.nativeAd = nativeSimpleAd;

// Add as subview
[self.view addSubView:self.nativeSimpleAdView];
}

On Ad Load Failure

- (void)adLoader:(GFPAdLoader *)unifiedAdLoader didFailWithError:(GFPError *)error responseInfo:(GFPLoadResponseInfo *)responseInfo {
...
}
info

Use GFPNativeSimpleAd estimateHeightWith: to set height of the ad view.

Ad Size changed afterward load are sent through GFPNativeSimpleAdDelegate nativeSimpleAd:didChangeMediaViewSizeWith:.

GFPNativeSimpleAdDelegate

On View Impression

- (void)nativeSimpleAdWasSeen:(GFPNativeSimpleAd *)nativeSimpleAd {
...
}

On Click

- (void)nativeSimpleAdWasClicked:(GFPNativeSimpleAd *)nativeSimpleAd {
...
}

On Rendering Error

- (void)nativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd didFailWithError:(GFPError *)error {
...
}

On Media View Size Change

didChangeMediaViewSizeWith: delivers GFPNativeSimpleAdView.mediaView's size change, wich is the size of its content.

Be minded that it does not mean that GFPNativeSimpleAdView resizes automatically. On didChangeMediaViewSizeWith: called, adjust the frame of GFPNativeSimpleAdView tailored for your app.

- (void)nativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd didChangeMediaViewSizeWith:(CGSize)size {
...
}

On Premium Rich Media View Size Change

It notifies media view's size change, but only applies to Premium Rich Ads.

- (void)nativeSimpleAd:(GFPNativeSimpleAd *)nativeSimpleAd didChangeRichAdSizeWith:(CGSize)size {
...
}

On Ad Muted

“Ad Mute” button on a corner of the ad, providing users options to hide unwanted ads.

On muted, banner view will show “Ad is blocked. NAVER will not show this ad again.” message instead of ad. Than it is app’s choice whether to completely remove the banner view using this delegate method.

- (void)nativeSimpleAdWasMuted:(GFPNativeSimpleAd *)nativeSimpleAd {

}