Interstitial Ad
eCPM의 통화(Currency) 단위는 USD입니다.
#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 {
// Firebase Analytics 샘플
[FIRAnalytics logEventWithName:kFIREventAdImpression parameters: @{
kFIRParameterAdPlatform: @"AD(X)",
kFIRParameterAdFormat: @"InterstitialAd",
kFIRParameterAdUnitName: @"ADX Interstitial Ad",
kFIRParameterCurrency: @"USD",
kFIRParameterValue: revenune
}];
// 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) {
// Firebase Analytics 샘플
Analytics.logEvent(
AnalyticsEventAdImpression,
parameters: [
AnalyticsParameterAdPlatform: "AD(X)",
AnalyticsParameterAdUnitName: "ADX Interstitial Ad",
AnalyticsParameterAdFormat: "InterstitialAd",
AnalyticsParameterValue: revenune,
AnalyticsParameterCurrency: "USD",
])
// 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