Rewarded Ad

1. Basic requirements

  • Add ​ADX Unity SDK to your project.

  • Use the Ad Unit ID issued for Banner Ads.

  • Before requesting an ad, SDK initialization must be done first.

    • SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.

2. Implementation

  1. If the app is distributed on both Android and iOS, enter the Ad Unit ID issued for each platform.

  2. Instantiate AdxRewardedAd and register the required callbacks.

  3. Call Load() to load the ad.

  4. When disposing of the ad object, call Destroy().

Loading Rewarded Ads may take some time, so it is recommended to preload them in advance before use.

#if UNITY_ANDROID
    string adxRewardedAdUnitId = "<ANDROID_ADX_REWARDED_AD_UNIT_ID>";
#elif UNITY_IOS
    string adxRewardedAdUnitId = "<IOS_ADX_REWARDED_AD_UNIT_ID>";
#endif

void LoadRewardedAd()
{
    if (rewardedAd == null)
    {
        rewardedAd = new AdxRewardedAd(adxRewardedAdUnitId);
        rewardedAd.OnRewardedAdLoaded += RewardedAd_OnRewardedAdLoaded;
        rewardedAd.OnRewardedAdFailedToLoad += RewardedAd_OnRewardedAdFailedToLoad;
        rewardedAd.OnRewardedAdShown += RewardedAd_OnRewardedAdShown;
        rewardedAd.OnRewardedAdClicked += RewardedAd_OnRewardedAdClicked;
        rewardedAd.OnRewardedAdFailedToShow += RewardedAd_OnRewardedAdFailedToShow;
        rewardedAd.OnRewardedAdEarnedReward += RewardedAd_OnRewardedAdEarnedReward;
        rewardedAd.OnRewardedAdClosed += RewardedAd_OnRewardedAdClosed;
    }

    rewardedAd.Load();
}
  • Check whether an ad is available using IsLoaded(), and if so, display the ad with Show().

void ShowRewardedAd()
{
    if (rewardedAd != null && rewardedAd.IsLoaded()) {
        rewardedAd.Show();
    }
}
  • When disposing of the ad object, call Destroy()

void DestroyRewardedAd()
{
    if (rewardedAd != null) {
        rewardedAd.Destroy();
        rewardedAd = null;
    }
}

3. Callback

You can receive specific events. Please implement them as needed.

public event Action OnRewardedAdLoaded = delegate { };
public event Action<int> OnRewardedAdFailedToLoad = delegate { };
public event Action OnRewardedAdShown = delegate { };
public event Action OnRewardedAdClicked = delegate { };
public event Action OnRewardedAdFailedToShow = delegate { };
public event Action OnRewardedAdEarnedReward = delegate { };
public event Action OnRewardedAdClosed = delegate { };
public event Action<double> OnPaidEvent = delegate { };

4. Ad Revenue (OnPaidEvent)

You can check the estimated ad revenue for ad impressions.

  • As shown in the example below, use OnPaidEvent to check the estimated eCPM value.

  • Manually set values during mediation setup and actual values may be mixed, so it is recommended to treat this as an estimate.

  • The currency unit of eCPM is USD.

  • You can link ad revenue data with your MMP. For details, please refer to the SDK integration guides below:

rewardedAd.OnPaidEvent += RewardedAd_OnPaidEvent;

void RewardedAd_OnPaidEvent(double ecpm)
{
   double revenue = ecpm / 1000f;
   
   // Firebase Analytics Example
   var impressionParameters = new[] {
    new Firebase.Analytics.Parameter("ad_platform", "AD(X)"),
    new Firebase.Analytics.Parameter("ad_unit_name", "ADX Rewarded Ad"),
    new Firebase.Analytics.Parameter("ad_format", "RewardedAd"),
    new Firebase.Analytics.Parameter("value", revenue),
    new Firebase.Analytics.Parameter("currency", "USD")
   };

   Firebase.Analytics.FirebaseAnalytics.LogEvent("ad_impression", impressionParameters);
   
   // AppsFlyer Example
   Dictionary<string, string> dic = new Dictionary<string, string>();
   dic.Add("AdUnitName", "ADX Rewarded Ad")
   dic.Add("AdType", "RewardedAd");

   AppsFlyerAdRevenue.logAdRevenue("AD(X)", AppsFlyerAdRevenueMediationNetworkType.AppsFlyerAdRevenueMediationNetworkTypeCustomMediation, revenue, "USD", dic);
}

5. SSV (Server-side verification) Settings

  • SSV settings are optional and can be configured only if needed.

  • SSV allows the reward event to trigger a server-to-server callback via the Callback URL.

  • The conditions for using SSV are as follows:

    • A Rewarded Video type with a registered Callback URL must be configured in the dashboard.

    • A reward event must occur after the user has fully watched the video.

    • If necessary, set the User ID or Custom Data information via the SDK before requesting an ad.

  • If the client sets the User ID and Custom Data, they will be included in the Callback URL request.

    • Example: https://callback_url?param=value&userid=<value>&customdata=<value>

    • SSV settings must be configured before the ad request to ensure the Callback URL includes the data.

  • Refer to the server-side SSV callback verification guide to verify the reward.

// SSV Settings (optional)
rewardedAd.SetUserIdForSSV("<USER_ID>");
rewardedAd.SetCustomDataForSSV("<CUSTOM_DATA>");
// Ad request
rewardedAd.Load();

Last updated

Was this helpful?