> For the complete documentation index, see [llms.txt](https://lionstudios.gitbook.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lionstudios.gitbook.io/readme/features/ads/displaying-ads.md).

# Displaying Ads

### Displaying an Interstitial Ad <a href="#displaying-an-interstitial-a-d" id="displaying-an-interstitial-a-d"></a>

Interstitial ads are shown manually when needed, usually during natural breaks in gameplay such as between levels or after an action is completed.

Use `TryShowInterstitial` to attempt to show an interstitial ad. This method returns `true` if the ad was shown successfully, and `false` if an interstitial ad was not available.

```csharp
public static bool TryShowInterstitial(
    string placement,
    Action onClosed = null,
    Dictionary<string, object> additionalData = null)
```

* **Placement**: A string identifier used to track where the ad was shown from.
* **On Closed**: Optional callback invoked when the ad is closed.
* **Additional Data**: Optional metadata for analytics or reporting.

**Example**

```csharp
private void ShowInterstitialAd()
{
    const string placement = "level_complete";

    if (LionAds.TryShowInterstitial(placement, AdClosed))
    {
        Debug.Log("Interstitial ad shown.");
    }
    else
    {
        Debug.Log("Interstitial ad not available.");
    }
}

private void AdClosed()
{
    Debug.Log("Interstitial ad closed.");
}
```

### Displaying a Rewarded Ad <a href="#displaying-a-rewarded-a-d" id="displaying-a-rewarded-a-d"></a>

Rewarded ads are shown manually when you want to offer a user a reward in exchange for watching an ad.

Use `TryShowRewarded` to attempt to show a rewarded ad. This method returns `true` if the ad was shown successfully, and `false` if a rewarded ad was not available.

```csharp
public static bool TryShowRewarded(
    string placement,
    Action onRewarded,
    Action onClosed = null,
    Reward reward = null,
    Dictionary<string, object> additionalData = null)
```

* **Placement**: A string identifier used to track where the ad was shown from.
* **On Rewarded:** Called when the user earns the reward.
* **On Closed**: Optional callback invoked when the ad is closed.
* **Reward**: Optional reward data associated with the ad for analytics or reporting
* **Additional Data:** Optional metadata for analytics or reporting.

**Example**

```csharp
private void ShowRewardedAd()
{
    const string placement = "double_coins";

    if (LionAds.TryShowRewarded(placement, GrantReward, AdClosed))
    {
        Debug.Log("Rewarded ad shown.");
    }
    else
    {
        Debug.Log("Rewarded ad not available.");
    }
}

private void GrantReward()
{
    Debug.Log("Grant reward.");
}

private void AdClosed()
{
    Debug.Log("Ad closed.");
}
```

### Displaying Banner Ads <a href="#displaying-a-banner" id="displaying-a-banner"></a>

Banner ads are loaded automatically during SDK initialization. You can customize the banner experience using the settings below:

<figure><img src="/files/g3bm6ycki6dHGZLHvd71" alt=""><figcaption></figcaption></figure>

* **Position**: Where the banner will be displayed on screen.
* **Color**: The background color behind the banner.
* **Disable Adaptive**: Disables adaptive banners. (Not recommended)
* **Disable Show Immediate**: When enabled, banners are loaded but not shown automatically. Call `ShowBanner()` manually to display them.

  When disabled, banners are shown automatically once loaded.

{% hint style="warning" %}
Make sure to call banner functions only after the banner has finished loading. Otherwise, a warning will be logged and no action will be taken.
{% endhint %}

**Show Banner**

```
LionAds.ShowBanner();
```

**Hide Banner**

```
LionAds.HideBanner();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://lionstudios.gitbook.io/readme/features/ads/displaying-ads.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
