Banner Ad
eCPM의 통화(Currency) 단위는 USD입니다.
#import <UIKit/UIKit.h>
#import <ADXLibrary/ADXAdView.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>
@interface BannerViewController () <ADXAdViewDelegate>
@property (strong) ADXAdView * bannerView;
@end
@implementation BannerViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.bannerView = [[ADXAdView alloc]
initWithAdUnitId:@"<ADX_BANNER_AD_UNIT_ID>"
adSize:ADXAdSizeBanner
rootViewController:self];
self.bannerView.delegate = self;
__weak typeof(self) weakSelf = self;
self.bannerView.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: @"BannerAd",
kFIRParameterAdUnitName: @"ADX Banner Ad",
kFIRParameterCurrency: @"USD",
kFIRParameterValue: revenune
}];
// AppsFlyer 샘플
NSDictionary * adRevenueParams = @{
@"AdUnitName" : @"ADX Banner Ad",
@"AdType" : @"BannerAd",
};
AppsFlyerAdRevenue * appsFlyerAdRevenue = [AppsFlyerAdRevenue shared];
[appsFlyerAdRevenue
logAdRevenueWithMonetizationNetwork:@"AD(X)"
mediationNetwork:AppsFlyerAdRevenueMediationNetworkTypeCustom
eventRevenue:revenune
revenueCurrency:@"USD"
additionalParameters:adRevenueParams];
}
#pragma mark - ADXAdViewDelegate
- (void)adViewDidLoad:(ADXAdView *)adView {}
- (void)adView:(ADXAdView *)adView didFailToLoadWithError:(NSError *)error {}
- (void)adViewDidClick:(ADXAdView *)adView {}
@end
import UIKit
import ADXLibrary
import FirebaseAnalytics
import AppsFlyerAdRevenue
class BannerAdViewController: UIViewController {
var bannerView : ADXAdView!
override func viewDidLoad() {
super.viewDidLoad()
bannerView = ADXAdView(adUnitId: "<ADX_BANNER_AD_UNIT_ID>")
bannerView.delegate = self
bannerView.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 Banner Ad",
AnalyticsParameterAdFormat: "BannerAd",
AnalyticsParameterValue: revenune,
AnalyticsParameterCurrency: "USD",
])
// AppsFlyer 샘플
let adRevenueParams:[AnyHashable: Any] = [
"AdUnitName" : "ADX Banner Ad",
"AdType" : "BannerAd",
]
AppsFlyerAdRevenue.shared().logAdRevenue(
monetizationNetwork: "AD(X)",
mediationNetwork: .custom,
eventRevenue: revenune,
revenueCurrency: "USD",
additionalParameters: adRevenueParams)
}
}
extension BannerViewController: ADXAdViewDelegate {
func adViewDidLoad(_ adView: ADXAdView) {}
func adView(_ adView: ADXAdView, didFailToLoadWithError error: Error) {}
func adViewDidClick(_ adView: ADXAdView) {}
}
Last updated