Skip to main content

Documentation Index

Fetch the complete documentation index at: https://guide.daro.so/llms.txt

Use this file to discover all available pages before exploring further.

Rewarded Video Ad Format

  • User-initiated video ads that grant rewards after completed views.
  • Grant rewards only from the OnEarnedReward event.

Integrating Ads

1

Create Ad Instance

private DaroRewardedAd ad;

ad = new DaroRewardedAd("your-rewarded-ad-unit-id");
2

Register Event Handlers

ad.OnAdLoaded += info => Debug.Log("rewarded loaded");
ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
ad.OnEarnedReward += (info, reward) =>
{
    Debug.Log($"earned {reward.Amount} {reward.RewardType}");
};
3

Load Ad

ad.Load();
4

Show Ad

if (ad != null && ad.IsReady())
{
    ad.SetCustomData("user=12345");
    ad.Show();
}
5

Dispose Ad

ad?.Dispose();
ad = null;

Example

using Daro;
using UnityEngine;

public sealed class RewardedHost : MonoBehaviour
{
    [SerializeField] private string adUnitId = "your-rewarded-ad-unit-id";
    private DaroRewardedAd ad;

    private void OnEnable()
    {
        ad = new DaroRewardedAd(adUnitId);
        ad.OnAdLoaded += info => Debug.Log("rewarded loaded");
        ad.OnAdFailedToLoad += error => Debug.LogWarning(error.Message);
        ad.OnEarnedReward += OnEarnedReward;
        ad.OnAdDismissed += info => ad?.Load();
        ad.Load();
    }

    public void ShowForReward()
    {
        if (ad != null && ad.IsReady())
        {
            ad.SetCustomData("user=12345");
            ad.Show();
        }
    }

    private void OnEarnedReward(DaroAdInfo info, DaroRewardItem reward)
    {
        Debug.Log($"earned {reward.Amount} {reward.RewardType}");
        // Grant the in-game reward here.
    }

    private void OnDisable()
    {
        ad?.Dispose();
        ad = null;
    }
}
Do not grant rewards from OnAdDismissed. OnEarnedReward fires only after the user completes the ad.