# 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
);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bidapp.io/plugins/unity/rewarded-ads.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
