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
import UIKit
import ADXLibrary
import FirebaseAnalytics
import AppsFlyerAdRevenue
class RewardedViewController: UIViewController, ADXRewardedAdDelegate {
var rewardedAd: ADXRewardedAd!
override func viewDidLoad() {
super.viewDidLoad()
rewardedAd = ADXRewardedAd(adUnitId: "<ADX_REWARDED_AD_UNIT_ID>")
rewardedAd.delegate = self
rewardedAd.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 Rewarded Ad",
AnalyticsParameterAdFormat: "RewardedAd",
AnalyticsParameterValue: revenune,
AnalyticsParameterCurrency: "USD",
])
// AppsFlyer 샘플
let adRevenueParams:[AnyHashable: Any] = [
"AdUnitName" : "ADX Rewarded Ad",
"AdType" : "RewardedAd",
]
AppsFlyerAdRevenue.shared().logAdRevenue(
monetizationNetwork: "AD(X)",
mediationNetwork: .custom,
eventRevenue: revenune,
revenueCurrency: "USD",
additionalParameters: adRevenueParams)
}
}
extension RewardedAdViewController: ADXRewardedAdDelegate {
func rewardedAdDidLoad(_ rewardedAd: ADXRewardedAd) {}
func rewardedAd(_ rewardedAd: ADXRewardedAd, didFailToLoadWithError error: Error) {}
func rewardedAd(_ rewardedAd: ADXRewardedAd, didFailToShowWithError error: Error) {}
func rewardedAdWillPresentScreen(_ rewardedAd: ADXRewardedAd) {}
func rewardedAdWillDismissScreen(_ rewardedAd: ADXRewardedAd) {}
func rewardedAdDidDismissScreen(_ rewardedAd: ADXRewardedAd) {}
func rewardedAdDidClick(_ rewardedAd: ADXRewardedAd) {}
func rewardedAdDidRewardUser(_ rewardedAd: ADXRewardedAd, with reward: ADXReward) {}
}
Last updated