Skip to main content

Native Special Ad

info

This is a settings guide for Special Ad (= RichMedia) products provided by Naver (NDP).

Image

Adding Dependencies

To use Rich Media ads, the following dependencies must be added to your Podfile.
The GFPSDK Core module along with the NDA, NDAVideo, and NDARich modules are required.

#When using static library

pod 'GFPSDK' # SDK Core
pod 'GFPSDK/MediationNDA' # Naver Banner/Native Ads
pod 'GFPSDK/MediationNDAVideo' # Naver Video Ad (since 4.3.0)
pod 'GFPSDK/MediationNDARich' # Naver Premium Ad (since 4.3.0)

#When using dynamic library

pod 'GFPSDK-Dynamic' # SDK Core
pod 'GFPSDK-Dynamic/MediationNDA' # Naver Banner/Native Ads
pod 'GFPSDK-Dynamic/MediationNDAVideo' # Naver Video Ad (since 4.3.0)
pod 'GFPSDK-Dynamic/MediationNDARich' # Naver Premium Ad (since 4.3.0)

Loader Configuration

Rich Media products are provided in the form of NativeSimple (aka. NS).
Please refer to the NS guide to configure the ad loader.

Additional GFPNativeSimpleAdDelegate Implementation

Unlike regular NS, Rich Media products have a vertical expand/collapse feature, so an ad view size change event is sent to the service when expanding or collapsing.
The service can apply the change by adjusting the ad view using the size value received from the corresponding delegate.

func nativeSimpleAd(_ nativeSimpleAd: GFPNativeSimpleAd, didChangeRichAdSizeWith size: CGSize) {
// ...
}
info

Starting from version 7.5.2, delegates have been added to notify the start and end of expand/collapse.

func nativeSimpleRichAdExtendComplete(_ nativeSimpleAd: GFPNativeSimpleAd) {
// Expand complete
}

func nativeSimpleRichAdExtendStart(_ nativeSimpleAd: GFPNativeSimpleAd, toSize size: CGSize) {
// Expand started, final expanded size delivered
}

func nativeSimpleRichAdShrinkComplete(_ nativeSimpleAd: GFPNativeSimpleAd) {
// Collapse complete
}

func nativeSimpleRichAdShrinkStart(_ nativeSimpleAd: GFPNativeSimpleAd, toSize size: CGSize) {
// Collapse started, final collapsed size delivered
}

Special DA Minimum Exposure Height

Returns the minimum visible area height that the service must guarantee for Special DA Double Crown and Triple Crown ads.

func minimumSpecialDaRegionHeight() -> CGFloat {
return 100
}

GFPNativeVideoEventDelegate

To receive rich ad video playback state changes, implement GFPNativeVideoEventDelegate and register it on the videoEventDelegate property of GFPNativeSimpleAdRenderingSetting.

nativeSimpleOptions.simpleAdRenderingSetting.videoEventDelegate = self
func nativeAd(_ nativeAd: NSObject, richVideoWillPlayWith isMuted: Bool) {
// Just before video playback
}

func nativeAd(_ nativeAd: NSObject, richVideoDidPlayWith isMuted: Bool) {
// State change after video playback starts
}

func nativeAd(_ nativeAd: NSObject, richVideoWillStopWith isMuted: Bool) {
// Just before video stops
}

func nativeAd(_ nativeAd: NSObject, richVideoDidStopWith isMuted: Bool) {
// State change after video stops
}

func nativeAd(_ nativeAd: NSObject, richVideoMuteChanged isMuted: Bool) {
// Mute state changed
}

Limiting Maximum Expand Height for Expandable Ads

info

Applies to certain ad products released after the Special DA Premium "New" Video Expandable type that provides 9:16, 16:9, and 1:1 ratio videos.

maxExtendingHeight is set as a block and can be dynamically changed even after an ad is loaded.
Setting it to 0 or below removes the height restriction.

let nativeSimpleOptions = GFPAdNativeSimpleOptions()
nativeSimpleOptions.simpleAdRenderingSetting = GFPNativeSimpleAdRenderingSetting()
nativeSimpleOptions.simpleAdRenderingSetting.maxExtendingHeight = { 50 }
self.adLoader?.setNativeSimpleDelegate(self, nativeSimpleOptions: nativeSimpleOptions)

Querying the Aspect Ratio of Expandable Ad Media

info

Applies to certain ad products released after the Special DA Premium "New" Video Expandable type that provides 9:16, 16:9, and 1:1 ratio videos.

func adLoader(_ adLoader: GFPAdLoader, didReceive nativeSimpleAd: GFPNativeSimpleAd) {
let mediaSize = nativeSimpleAd.mediaData?.richMediaData?.extendMediaSize
let ratioType = nativeSimpleAd.mediaData?.richMediaData?.extendMediaAspectRatioType
// GFPRichExtendMediaRatioTypeOther
// GFPRichExtendMediaRatioType1_1
// GFPRichExtendMediaRatioType9_16
// GFPRichExtendMediaRatioType16_9
}

Parallel Configuration with Standard Format

info

The default height for Rich Media is 140.

Rich Media products are provided as a combination of Rich Media products and regular image-type ads.
When the service cannot dynamically adjust the ad vertical area depending on whether the ad is an image type or a Rich Media product,
e.g., when a fixed size must be maintained regardless of image type / rich type at the start of an ad,
there is an isImageSizePreferred setting that arranges image-type ads centered at the bottom-right, prioritizing the image size regardless of the ad area.

let simpleSetting = GFPNativeSimpleAdRenderingSetting()
simpleSetting.preferredAdChoicesViewPosition = .topRightCorner
simpleSetting.isImageSizePreferred = true

let nativeSimpleOptions = GFPAdNativeSimpleOptions()
nativeSimpleOptions.simpleAdRenderingSetting = simpleSetting

// ...

self.adLoader?.setNativeSimpleDelegate(self, nativeSimpleOptions: nativeSimpleOptions)

If a flexible response is possible, you can handle it using the following method of GFPNativeSimpleAdDelegate.

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

Triple Crown / Double Crown Background View Configuration

Triple Crown and Double Crown ads use a background view and an object view from the service's surface behind the ad view.
Add them to the view hierarchy in advance, then pass them to GFPNativeSimpleAdView's additionalRenderingViewDict using the keys below.

Key ConstantPurpose
kTripleCrownBgViewTriple Crown background view (background video is inserted)
kTripleCrownTopObjectViewTriple Crown top object view (ad logo is inserted)
kDoubleCrownBgViewDouble Crown background view (background video is inserted)
warning

additionalRenderingViewDict must be set before setting nativeSimpleAdView.nativeAd.

If both kTripleCrownBgView and kTripleCrownTopObjectView are not provided for Triple Crown, the SDK automatically renders a fallback ad format.

// 1. 배경 뷰들을 뷰 계층에 추가
let tripleCrownBGView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 400))
tripleCrownBGView.isUserInteractionEnabled = true
scrollView.addSubview(tripleCrownBGView)

let doubleCrownBGView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 300))
doubleCrownBGView.isUserInteractionEnabled = true
scrollView.addSubview(doubleCrownBGView)

let tripleCrownObjectView = UIView(frame: CGRect(x: 0, y: 0, width: view.bounds.width, height: 200))
tripleCrownObjectView.isUserInteractionEnabled = true
scrollView.addSubview(tripleCrownObjectView)

// 2. nativeAd 설정 전에 additionalRenderingViewDict 전달
nativeSimpleAdView.additionalRenderingViewDict = [
kTripleCrownBgView as String: tripleCrownBGView,
kTripleCrownTopObjectView as String: tripleCrownObjectView,
kDoubleCrownBgView as String: doubleCrownBGView
]
nativeSimpleAdView.nativeAd = nativeSimpleAd

Checking the Ad Type

To check whether the received ad is Triple Crown or Double Crown, use the kGFPMediaViewType key in nativeSimpleAd.assets.extraInfo.

let mediaType = nativeSimpleAd.assets?.extraInfo?[kGFPMediaViewType] as? NSNumber
if mediaType?.intValue == GFPExternalMediaViewType.tripleCrown.rawValue {
// Triple Crown ad
} else if mediaType?.intValue == GFPExternalMediaViewType.doubleCrown.rawValue {
// Double Crown ad
}

Retrieving Triple Crown Special Logo Information

Special logo information for Triple Crown ads (e.g., for changing logo color) is provided as a JSON string.
Retrieve it using the kGFPNaverAppLogoInfoKey key.

let logoJsonString = nativeSimpleAd.assets?.extraInfo?[kGFPNaverAppLogoInfoKey] as? String

Special DA Bottom-Only Expand Configuration

By default, Special DA uses an expansion method that includes a top margin.
To expand only downward without a top margin, set enableSpecialDABottomExtend.

let simpleSetting = GFPNativeSimpleAdRenderingSetting()
simpleSetting.enableSpecialDABottomExtend = true

Special DA Layout Configuration

Options used to adjust the detailed layout of Special DA ads.

PropertyTypeDescription
specialDAOverlayHeightCGFloatHeight value for overlap with the widget surface
specialDAAdditionalMarginCGFloatAdditional widget margin value
specialDAGradientHeightCGFloatGradient height at the bottom of the ad
v1GradientBOOLWhether to use the v1 gradient at the bottom of the MediaView
let simpleSetting = GFPNativeSimpleAdRenderingSetting()
simpleSetting.specialDAOverlayHeight = 44
simpleSetting.specialDAAdditionalMargin = 8
simpleSetting.specialDAGradientHeight = 60
simpleSetting.v1Gradient = true