> For the complete documentation index, see [llms.txt](https://docs.bidapp.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bidapp.io/plugins/unity/rewarded-ads.md).

# Rewarded Ads

## Load

Rewarded Ads start loading automatically right after creation an instance:

```csharp
string rewardedIdentifier = BidappBinding.Instance.CreateRewarded();
```

From creation function you will obtain an **Rewarded Ad identifier** that will be required to show and destroy ads, receive callbacks.

To check if Rewarded Ad is Ready to be displayed you may use next function:

```csharp
BidappBinding.Instance.IsRewardedAdReady(rewardedIdentifier);
```

## Show

To show an reward ad, call `showRewarded` instance function:

```csharp
BidappBinding.Instance.ShowRewarded(rewardedIdentifier);
```

## Destroy with resource release

Call the following function to destroy a rewarded:

```csharp
BidappBinding.Instance.DestroyRewarded(rewardedIdentifier);
```

{% hint style="info" %}
`DestroyRewarded` functions will also unregister all callback receiver instances, registered for the specified `rewardedIdentifier`
{% endhint %}

## Callbacks / Delegates / Events

### Register

To be able to register reward callbacks receiver you will need to inherit it from `IBidappRewardedDelegate`

```csharp
public class BidappRewardedDelegate : IBidappRewardedDelegate
```

Then you need to register receiver of the callbacks for rewarded instance identifier:

```csharp
BidappSDKDelegate.Instance.SetRewardedDelegate(
    new BidappRewardedDelegate(),
    rewardedIdentifier
);
```

### Observe

You can observe ad loading events in callbacks:

```csharp
public void OnRewardedDidLoadAd(string identifier, string networkId)
{
    Debug.Log($"BIDUnity OnRewardedDidLoadAd: rewardedId {identifier}, providerId: {networkId}");
}

public void OnRewardedDidFailToLoadAd(string identifier, string networkId, string errorDescription)
{
    Debug.Log($"BIDUnity OnRewardedDidFailToLoadAd: rewardedId {identifier}, providerId: {networkId}, errorDescription: {errorDescription}");
}
```

Events related to displaying rewarded ad can be observed in callbacks:

```csharp
public void OnRewardedDidDisplayAd(string identifier, string networkId)
{
    Debug.Log($"BIDUnity OnRewardedDidDisplayAd: rewardedId {identifier}, providerId: {networkId}");
}

public void OnRewardedDidClickAd(string identifier, string networkId)
{
    Debug.Log($"BIDUnity OnRewardedDidClickAd: rewardedId {identifier}, providerId: {networkId}");
}

public void OnRewardedDidHideAd(string identifier, string networkId)
{
    Debug.Log($"BIDUnity OnRewardedDidHideAd: rewardedId {identifier}, providerId: {networkId}");
}

public void OnRewardedDidFailToDisplayAd(string identifier, string networkId, string errorDescription)
{
    Debug.Log($"BIDUnity OnRewardedDidFailToDisplayAd: rewardedId {identifier}, providerId: {networkId}, errorDescription: {errorDescription}");
}

public void OnRewardedAllNetworksFailedToDisplayAd(string identifier)
{
    Debug.Log($"BIDUnity OnRewardedAllNetworksFailedToDisplayAd: rewardedId {identifier}");
}
```

To be notified when user should be rewarded implement use callback:

```csharp
public void OnUserDidReceiveReward(string identifier)
{
    Debug.Log($"BIDUnity OnUserDidReceiveReward: rewardedId {identifier}");
}
```

### Release

If you don't want to receive callbacks anymore you can unregister callback receiver instance:

```csharp
BidappSDKDelegate.Instance.SetRewardedDelegate(
    null,
    rewardedIdentifier
);
```
