> ## Documentation Index
> Fetch the complete documentation index at: https://beta-guide.daro.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Rewarded Video Ads

> Implement rewarded video ads in your Unity project.

## Rewarded Video Ad Format

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

***

## Integrating Ads

<Steps>
  <Step title="Create Ad Instance">
    ```csharp theme={null}
    private DaroRewardedAd ad;

    ad = new DaroRewardedAd("your-rewarded-ad-unit-id");
    ```
  </Step>

  <Step title="Register Event Handlers">
    ```csharp theme={null}
    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}");
    };
    ```
  </Step>

  <Step title="Load Ad">
    ```csharp theme={null}
    ad.Load();
    ```
  </Step>

  <Step title="Show Ad">
    ```csharp theme={null}
    if (ad != null && ad.IsReady())
    {
        ad.SetCustomData("user=12345");
        ad.Show();
    }
    ```
  </Step>

  <Step title="Dispose Ad">
    ```csharp theme={null}
    ad?.Dispose();
    ad = null;
    ```
  </Step>
</Steps>

***

## Example

```csharp expandable theme={null}
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;
    }
}
```

<Warning>
  Do not grant rewards from `OnAdDismissed`. `OnEarnedReward` fires only after the user completes the ad.
</Warning>
