Interstitial Ad
1. 기본 요건
ADX iOS SDK를 프로젝트에 추가합니다.
Interstitial Ad용으로 발급받은 Ad Unit ID를 사용합니다.
광고를 요청하기 전에 SDK 초기화를 먼저 진행합니다.
SDK 초기화는 앱 실행 시 한 번만 호출하여 주시고, 광고 요청은 초기화가 완료된 후에 이뤄져야 합니다.
iOS 14 이상 지원하는 경우, ATT(App Tracking Transparency) 권한 요청 완료 후 광고를 요청해주세요.
2. 구현
initWithAdUnitId:
메서드를 사용하여ADXInterstitialAd
를 인스턴스화하고ADXInterstitialAdDelegate
callback을 등록합니다.loadAd
를 호출하여 광고를 로드합니다.isLoaded
로 표시할 광고가 있는지 확인 후,showAdFromRootViewController:
로 광고를 표시합니다.
#import <ADXLibrary/ADXInterstitialAd.h>
@interface InterstitialViewController () <ADXInterstitialAdDelegate>
@property (strong) ADXInterstitialAd *interstitialAd;
@end
@implementation InterstitialViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitialAd = [[ADXInterstitialAd alloc]
initWithAdUnitId:@"<ADX_INTERSTITIAL_AD_UNIT_ID>"];
self.interstitialAd.delegate = self;
}
- (IBAction)loadAd:(id)sender {
[self.interstitialAd loadAd];
}
- (IBAction)showAd:(id)sender {
if (self.interstitialAd.isLoaded) {
[self.interstitialAd showAdFromRootViewController:self];
}
}
#pragma mark - ADXInterstitialAdDelegate
- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitial {
NSLog(@"interstitialAdDidLoad");
}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToLoadWithError:(NSError *)error {
NSLog(@"interstitialAd:didFailToLoadWithError: %@", error);
}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToShowWithError:(NSError *)error {
NSLog(@"interstitialAd:didFailToShowWithError: %@", error);
}
- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdWillPresentScreen");
}
- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdWillDismissScreen");
}
- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdDidDismissScreen");
}
- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd {
NSLog(@"interstitialAdDidClick");
}
@end
import UIKit
import ADXLibrary
class InterstitialViewController: UIViewController {
fileprivate var interstitialAd: ADXInterstitialAd!
override func viewDidLoad() {
super.viewDidLoad()
interstitialAd = ADXInterstitialAd(adUnitId:
"<ADX_INTERSTITIAL_AD_UNIT_ID>");
interstitialAd.delegate = self
}
@IBAction func loadAd(_ sender: Any) {
interstitialAd.load()
}
@IBAction func showAd(_ sender: Any) {
if interstitialAd.isLoaded {
interstitialAd.show(fromRootViewController: self)
}
}
}
extension InterstitialViewController: ADXInterstitialAdDelegate {
func interstitialAdDidLoad(_ interstitialAd: ADXInterstitialAd) {
print("interstitialAdDidLoad")
}
func interstitialAd(_ interstitialAd: ADXInterstitialAd, didFailToLoadWithError error: Error) {
print("interstitialAd didFailToLoadWithError")
}
func interstitialAd(_ interstitialAd: ADXInterstitialAd, didFailToShowWithError error: Error) {
print("interstitialAd didFailToShowWithError")
}
func interstitialAdWillPresentScreen(_ interstitialAd: ADXInterstitialAd) {
print("interstitialAdWillPresentScreen")
}
func interstitialAdWillDismissScreen(_ interstitialAd: ADXInterstitialAd) {
print("interstitialAdWillDismissScreen")
}
func interstitialAdDidDismissScreen(_ interstitialAd: ADXInterstitialAd) {
print("interstitialAdDidDismissScreen")
}
func interstitialAdDidClick(_ interstitialAd: ADXInterstitialAd) {
print("interstitialAdDidClick")
}
}
3. Callback
ADXInterstitialAdDelegate
를 설정하여 특정 이벤트를 수신할 수 있습니다.
- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd;
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd
didFailToLoadWithError:(NSError *)errorr;
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd
didFailToShowWithError:(NSError *)error;
func func interstitialAdDidLoad(_ interstitialAd: ADXInterstitialAd)
func interstitialAdWillPresentScreen(_ interstitialAd: ADXInterstitialAd)
func interstitialAdWillDismissScreen(_ interstitialAd: ADXInterstitialAd)
func interstitialAdDidDismissScreen(_ interstitialAd: ADXInterstitialAd)
func interstitialAdDidClick(_ interstitialAd: ADXInterstitialAd)
func interstitialAd(_ interstitialAd: ADXInterstitialAd,
didFailToLoadWithError error: Error)
func interstitialAd(_ interstitialAd: ADXInterstitialAd,
didFailToShowWithError error: Error)
4. Ad Revenue (paidEventHandler)
광고 노출에 대한 예상 광고 수익을 확인할 수 있습니다.
이 기능은 iOS ADX SDK 2.4.1 버전 이상에서 사용하는 것이 권장됩니다.
아래 예제와 같이'
paidEventHandler
' 를 사용하여 예상되는 eCPM 값을 확인할 수 있습니다.미디에이션 설정 과정에서 수동적으로 설정한 값과 정확한 값이 섞여 있어서 예상 값으로 사용하시는 것을 권장드립니다.
eCPM의 통화(Currency) 단위는 USD입니다.
AdJust의 광고 매출 데이터 연동을 지원합니다. 상세한 내용은 AdJust의 AD(X) SDK 연동 가이드를 확인 부탁드립니다.
#import <UIKit/UIKit.h>
#import <ADXLibrary/ADXInterstitialAd.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>
@interface InterstitialViewController () <ADXInterstitialAdDelegate>
@property (strong) ADXInterstitialAd *interstitialAd;
@end
@implementation InterstitialViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.interstitialAd = [[ADXInterstitialAd alloc]
initWithAdUnitId:@"<ADX_INTERSTITIAL_AD_UNIT_ID>"];
self.interstitialAd.delegate = self;
__weak typeof(self) weakSelf = self;
self.interstitialAd.paidEventHandler = ^(double eCPM) {
__strong typeof(self) strongSelf = weakSelf;
if(!strongSelf) { return; }
NSNumber * revenue = [NSNumber numberWithDouble:eCPM/1000];
[strongSelf handleAdRevenue:revenue];
};
}
- (void)handleAdRevenue:(NSNumber *)revenue {
// 1) Firebase Analytics
[FIRAnalytics logEventWithName:kFIREventAdImpression parameters: @{
kFIRParameterAdPlatform: @"AD(X)",
kFIRParameterAdFormat: @"InterstitialAd",
kFIRParameterAdUnitName: @"ADX Interstitial Ad",
kFIRParameterCurrency: @"USD",
kFIRParameterValue: revenune
}];
// 2) AppsFlyer
NSDictionary * adRevenueParams = @{
@"AdUnitName" : @"ADX Interstitial Ad",
@"AdType" : @"InterstitialAd",
};
AppsFlyerAdRevenue * appsFlyerAdRevenue = [AppsFlyerAdRevenue shared];
[appsFlyerAdRevenue
logAdRevenueWithMonetizationNetwork:@"AD(X)"
mediationNetwork:AppsFlyerAdRevenueMediationNetworkTypeCustom
eventRevenue:revenune
revenueCurrency:@"USD"
additionalParameters:adRevenueParams];
}
#pragma mark - ADXInterstitialAdDelegate
- (void)interstitialAdDidLoad:(ADXInterstitialAd *)interstitial {}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToLoadWithError:(NSError *)error {}
- (void)interstitialAd:(ADXInterstitialAd *)interstitialAd didFailToShowWithError:(NSError *)error {}
- (void)interstitialAdWillPresentScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdWillDismissScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdDidDismissScreen:(ADXInterstitialAd *)interstitialAd {}
- (void)interstitialAdDidClick:(ADXInterstitialAd *)interstitialAd {}
@end
import UIKit
import ADXLibrary
import FirebaseAnalytics
import AppsFlyerAdRevenue
class InterstitialViewController: UIViewController {
var interstitialAd: ADXInterstitialAd!
override func viewDidLoad() {
super.viewDidLoad()
interstitialAd = ADXInterstitialAd(adUnitId:
"<ADX_INTERSTITIAL_AD_UNIT_ID>")
interstitialAd.delegate = self
interstitialAd.paidEventHandler = { [weak self] eCPM in
let revenue:NSNumber = (eCPM / 1000) as NSNumber
self?.handleAdRevenue(revenue: revenue)
}
}
func handleAdRevenue(revenue:NSNumber) {
// 1) Firebase Analytics
Analytics.logEvent(
AnalyticsEventAdImpression,
parameters: [
AnalyticsParameterAdPlatform: "AD(X)",
AnalyticsParameterAdUnitName: "ADX Interstitial Ad",
AnalyticsParameterAdFormat: "InterstitialAd",
AnalyticsParameterValue: revenune,
AnalyticsParameterCurrency: "USD",
])
// 2) AppsFlyer
let adRevenueParams:[AnyHashable: Any] = [
"AdUnitName" : "ADX Interstitial Ad",
"AdType" : "InterstitialAd",
]
AppsFlyerAdRevenue.shared().logAdRevenue(
monetizationNetwork: "AD(X)",
mediationNetwork: .custom,
eventRevenue: revenune,
revenueCurrency: "USD",
additionalParameters: adRevenueParams)
}
}
extension InterstitialViewController: ADXInterstitialAdDelegate {
func interstitialAdDidLoad(_ interstitialAd: ADXInterstitialAd) {}
func interstitialAd(_ interstitialAd: ADXInterstitialAd, didFailToLoadWithError error: Error) {}
func interstitialAd(_ interstitialAd: ADXInterstitialAd, didFailToShowWithError error: Error) {}
func interstitialAdWillPresentScreen(_ interstitialAd: ADXInterstitialAd) {}
func interstitialAdWillDismissScreen(_ interstitialAd: ADXInterstitialAd) {}
func interstitialAdDidDismissScreen(_ interstitialAd: ADXInterstitialAd) {}
func interstitialAdDidClick(_ interstitialAd: ADXInterstitialAd) {}
}
Last updated