Skip to main content

Getting Started

Native Simple ads contain single native view that conatins an image or rich native contents.

Prerequisites

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

class MyViewController : UIViewController, GFPAdLoaderDelegate, GFPNativeSimpleAdDelegate {
private var adLoader : GFPAdLoader?

private var nativeSimpleAd : GFPNativeSimpleAd?
private var nativeSimpleAdView : GFPNativeSimpleAdView?
}

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.

override func viewDidLoad() {
super.viewDidLoad()

let adParam = GFPAdParam()
adParam.yearOfBirth = 1990
adParam.gender = .male
...

self.adLoader = GFPAdLoader(unitID: "UnitId", rootViewController: self, adParam: adParam)

let nativeSimpleOption = GFPAdNativeSimpleOptions()
nativeSimpleOption.renderingSetting = ...
self.adLoader?.setNativeSimpleDelegate(self, nativeSimpleOptions: nativeSimpleOption)

self.adLoader?.delegate = self
self.adLoader?.loadAd()
}

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

func adLoader(_ unifiedAdLoader: GFPAdLoader!, didReceive nativeSimpleAd: GFPNativeSimpleAd!) {
// Get estimated ad height
let estimateHeight = nativeSimpleAd.estimateHeight(with: 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 = nativeAd

// Add as subview
self.view.addSubview(self.nativeSimpleAdView!)
}

On Ad Load Failure

func adLoader(_ unifiedAdLoader: GFPAdLoader!, didFailWithError error: GFPError!, responseInfo: GFPLoadResponseInfo!) {
...
}
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

func nativeSimpleAdWasSeen(_ nativeSimpleAd: GFPNativeSimpleAd) {
...
}

On Rendered Impression

func nativeSimpleAdWasRendered(_ nativeSimpleAd: GFPNativeSimpleAd) {
...
}

On Click

func nativeSimpleAdWasClicked(_ nativeSimpleAd: GFPNativeSimpleAd) {
...
}

On Rendering Error

func nativeSimpleAd(_ nativeSimpleAd: GFPNativeSimpleAd, didFailWithError error: GFPError) {
...
}

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.

func nativeSimpleAd(_ nativeSimpleAd: GFPNativeSimpleAd, didChangeMediaViewSizeWith size: CGSize) {
...
}

On Premium Rich Media View Size Change

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

func nativeSimpleAd(_ nativeSimpleAd: GFPNativeSimpleAd, 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.

func nativeSimpleAdWasMuted(_ nativeSimpleAd: GFPNativeSimpleAd) {

}