Rewarded Ad

eCPM의 통화(Currency) 단위는 USD입니다.

#import <UIKit/UIKit.h>
#import <ADXLibrary/ADXInterstitialAd.h>
#import <FirebaseAnalytics/FirebaseAnalytics.h>
#import <AppsFlyerAdRevenue/AppsFlyerAdRevenue.h>

@interface RewardedViewController () <ADXRewardedAdDelegate>
@property (strong) ADXRewardedAd *rewardedAd;
@end

@implementation RewardedViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.rewardedAd = [[ADXRewardedAd alloc] 
        initWithAdUnitId:@"<ADX_REWARDED_AD_UNIT_ID>"];
                                
    self.rewardedAd.delegate = self;
    
    __weak typeof(self) weakSelf = self;
    self.rewardedAd.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: @"RewardedAd",
        kFIRParameterAdUnitName: @"ADX Rewarded Ad",
        kFIRParameterCurrency: @"USD",
        kFIRParameterValue: revenune
    }];
        
    // AppsFlyer 샘플
    NSDictionary * adRevenueParams = @{
        @"AdUnitName" : @"ADX Rewarded Ad",
        @"AdType" : @"RewardedAd",
    };
    
    AppsFlyerAdRevenue * appsFlyerAdRevenue = [AppsFlyerAdRevenue shared];
    [appsFlyerAdRevenue 
        logAdRevenueWithMonetizationNetwork:@"AD(X)"
        mediationNetwork:AppsFlyerAdRevenueMediationNetworkTypeCustom
        eventRevenue:revenune
        revenueCurrency:@"USD"
        additionalParameters:adRevenueParams];
}

#pragma mark - ADXRewardedAdDelegate
- (void)rewardedAdDidLoad:(ADXRewardedAd *)rewardedAd {}
- (void)rewardedAd:(ADXRewardedAd *)rewardedAd didFailToLoadWithError:(NSError *)error {}
- (void)rewardedAd:(ADXRewardedAd *)rewardedAd didFailToShowWithError:(NSError *)error {}
- (void)rewardedAdWillPresentScreen:(ADXRewardedAd *)rewardedAd {}
- (void)rewardedAdDidClick:(ADXRewardedAd *)rewardedAd {}
- (void)rewardedAdWillDismissScreen:(ADXRewardedAd *)rewardedAd {}
- (void)rewardedAdDidDismissScreen:(ADXRewardedAd *)rewardedAd {}
- (void)rewardedAdDidRewardUser:(ADXRewardedAd *)rewardedAd withReward:(ADXReward *)reward {}

@end

Last updated