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

Last updated