#if UNITY_ANDROID
string adxInterstitialAdUnitId = "<ANDROID_ADX_INTERSTITIAL_AD_UNIT_ID>";
#elif UNITY_IOS
string adxInterstitialAdUnitId = "<IOS_ADX_INTERSTITIAL_AD_UNIT_ID>";
#endif
void LoadInterstitialAd()
{
if (interstitialAd == null)
{
interstitialAd = new AdxInterstitialAd(adxInterstitialAdUnitId);
interstitialAd.OnAdLoaded += InterstitialAd_OnAdLoaded;
interstitialAd.OnAdFailedToLoad += InterstitialAd_OnAdFailedToLoad;
interstitialAd.OnAdClicked += InterstitialAd_OnAdClicked;
interstitialAd.OnAdShown += InterstitialAd_OnAdShown;
interstitialAd.OnAdClosed += InterstitialAd_OnAdClosed;
interstitialAd.OnAdFailedToShow += InterstitialAd_OnAdFailedToShow;
}
interstitialAd.Load();
}
void ShowInterstitialAd()
{
if (interstitialAd != null && interstitialAd.IsLoaded()){
interstitialAd.Show();
}
}
void DestroyInterstitialAd()
{
if (interstitialAd != null){
interstitialAd.Destroy();
interstitialAd = null;
}
}
특정 이벤트를 수신할 수 있습니다. 필요에 따라 구현해주세요.
public event Action OnAdLoaded = delegate { };
public event Action<int> OnAdFailedToLoad = delegate { };
public event Action OnAdClicked = delegate { };
public event Action OnAdShown = delegate { };
public event Action OnAdClosed = delegate { };
public event Action OnAdFailedToShow = delegate { };
public event Action<double> OnPaidEvent = delegate { };
4. Ad Revenue (OnPaidEvent)
광고 노출에 대한 예상 광고 수익을 확인할 수 있습니다.
interstitialAd.OnPaidEvent += InterstitialAd_OnPaidEvent;
void InterstitialAd_OnPaidEvent(double ecpm)
{
/* Firebase Analytics 샘플
double revenue = ecpm / 1000f;
var impressionParameters = new[] {
new Firebase.Analytics.Parameter("ad_platform", "AD(X)"),
new Firebase.Analytics.Parameter("ad_unit_name", "ADX Interstitial Ad"),
new Firebase.Analytics.Parameter("ad_format", "InterstitialAd"),
new Firebase.Analytics.Parameter("value", revenue),
new Firebase.Analytics.Parameter("currency", "USD")
};
Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
*/
/* AppsFlyer 샘플
double revenue = ecpm / 1000f;
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("AdUnitName", "ADX Interstitial Ad")
dic.Add("AdType", "InterstitialAd");
AppsFlyerAdRevenue.logAdRevenue("AD(X)", AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeCustomMediation, revenue, "USD", dic);
*/
}