> 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/lionsdk-1.x-legacy-docs/ads.md).

# Lion Ads

This package simplifies showing ads from Max SDK.

It automatically handles:

* loading the ads
* sending required Lion Analytics Ad events

{% hint style="warning" %}
Do **not** call Lion Analytics’ **Ad events** if you use Lion Ads, or they will be sent **twice**.
{% endhint %}

{% hint style="warning" %}
Google Ads Manager requires its own set of IDs; enter those IDs in the MAX Integration Manager if Google Ads Manager is installed as an adapter.
{% endhint %}

{% hint style="warning" %}
**Manual Adjust Integration Required**\
\
If Adjust is initialised manually by devs (not through LionSDK) then they've to add the following code, failing to do so will cause WhoAmI service to malfunction and ads will not work.\
\
-> After your `Adjust.InitSdk()` call, you MUST invoke: `LionCore.AdjustInitialized();`
{% endhint %}

### Setup

Everything should already be setup if you previously ran the [Setup Wizard](/readme/getting-started.md#setup-wizard). This section is for verification and troubleshooting if needed.

#### 1. Check ad settings

* Open **LionStudios→Settings Manager → Ads** in the Unity menu
* Verify the following:

  * **Ad Unit Ids** are correctly setup
  * **Enable Lion Ads** is turned ON.

  <figure><img src="/files/JuscPRYTXGWQHXFjXytZ" alt="" width="563"><figcaption></figcaption></figure>

#### 2. Next steps

* If **Google Ads Manager** is installed as an adapter, it requires its own set of IDs; enter those IDs in the MAX Integration Manager by going to **AppLovin → Integration Manager** in the Unity menu.

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

* Now, if everything is setup correctly
  * Proceed to [Code Integration](#code-integration)
* If settings are incorrect or missing
  * Go to **LionStudios→Settings Manager → Ads** in the Unity menu
  * Turn ON the “Enable Lion Ads” checkbox
  * Fill up the required ad unit IDs
  * Leave the other settings to their default values unless requested

### Code Integration

Lion Ads provides just a few static functions to show and handle ads.

* **LionAds.**&#x49;sRewardedReady

  * returns: `boolean`

  Call this to decide whether to propose rewarded buttons or to disable them

  **Example**

  ```csharp
  private void UpdateButton()
  {
      rewardAdButton.gameObject.SetActive(LionAds.IsRewardedReady);
  }
  ```
* **LionAds.TryShowRewarded**`(string placement, Action onRewarded,Action onClosed = null, Reward reward = null, Dictionary<string, object> additionalData)`

  * returns: `boolean`: false if no ad was ready
  * parameters:
    * `placement`: a string describing this ad placement (ie: “SkinShop”, “SkipLevel”…)
    * `onRewarded`: a callback called when the player has watched through the ad. This should contain the code that gives the actual reward to the player.
    * `onClosed`(optional): a callback called when the ad was closed (completed or canceled). This can be used to resume normal flow after the ad.
    * `reward` (optional): this object will be passed in the automated call to `LionAnalytics.RewardVideoCollect`. (cf ‣)
    * `additionalData` (optional): this parameter will be passed to all ad events related to this ad (that is all RewardVideoX events except \_Load and \_LoadFail).

  Call this to show a rewarded video if available.

  **Example**

  ```csharp
  private void ShowRewarded()
  {
      //Optional
      Dictionary<string, object> additionalData = new Dictionary<string, object>()
      {
          { "mission_data", new Dictionary<string, object>()
              {
                  { "mission_type", "side" },
                  { "mission_name", "side_quest_1" },
                  { "mission_id", 101 },
                  { "mission_attempt", 1 }
              }
          }, 
          //Can add other custom values
          { "example_key1", "ExampleValue" },
          { "example_key2", "ExampleValue" }
      };
  		
      LionAds.TryShowRewarded("LevelStart", OnRewarded, OnRewardedAdClosed,
      GetTestReward(), additionalData);
  }

  private void OnRewarded()
  {
      Debug.Log("On reward received. Give user a reward here.");
  }

  //Optional
  private void OnRewardedAdClosed()
  {
      Debug.Log("On Rewarded ad closed");
  }

  //Optional
  //Reward = LionStudios.Suite.Analytics.Reward
  private Reward GetTestReward()
  {
    Reward testReward = new Reward("coins", "currency", 10);
    return testReward;
  }
  ```
* **LionAds.TryShowInterstitial**`(string placement**, Action onClosed = null, Dictionary<string, object> additionalData**)**`

  * returns: `boolean`: false if no ad was ready
  * parameters:
    * `placement`: a string describing this ad placement (ie: “LevelEnd”…)
    * `onClosed`(optional): a callback called when the ad was closed (completed or canceled or not ready). This can be used to resume normal flow after the ad.
    * `additionalData` (optional): this parameter will be passed to all ad events related to this ad (that is all InterstitialX events except \_Load and \_LoadFail).

  Call this to show an interstitial video if available.

  **Example**

  ```csharp
  private void ShowInterstitial()
  {
    //Optional
    Dictionary<string, object> additionalData = new Dictionary<string, object>()
    {
  		{ "mission_data", new Dictionary<string, object>()
  	    {
  	      { "mission_type", "main" },
  	      { "mission_name", "main_3" },
  	      { "mission_id", 3 },
  	      { "mission_attempt", 2 }
  	    }
  		},
  		//Can add other custom values
      { "example_key1", "ExampleValue" },
      { "example_key2", "ExampleValue" }
    };

    LionAds.TryShowInterstitial("LevelStart", OnInterClosed, additionalData);
  }

  //Optional
  private void OnInterClosed()
  {
      Debug.Log("Interstitial ad closed");
  }
  ```
* **LionAds.ShowBanner()**

  * returns: `boolean`: false if no ad was ready. Even if false is returned, it will still load and show the banner as soon as ready.

  Call this to show a banner ad as soon as available.

  The banner will be positioned according to the “Banner Position” setting.

  **Example**

  ```csharp
  private void ShowBanner()
  {
      LionAds.ShowBanner();
  }
  ```
* **LionAds.HideBanner()**

  * returns: `void`

  Call this to hide the banner ad.

  **Example**

  ```csharp
  private void HideBanner()
  {
      LionAds.HideBanner();
  }
  ```
* **LionAds.OnRewardedStatusChanged**

  * type: `Action<bool>`

  Subscribe to this event to update RV buttons status when a Rewarded becomes ready. This is to avoid having to call `IsRewardedReady` constantly.

  **Example**

  ```csharp
  private void SubscribeToRewardedAdStatus()
  {
      LionAds.OnRewardedStatusChanged += (flag) =>
      {
          rewardAdButton.gameObject.SetActive(flag);
      };
  }
  ```

#### CPM Floor Ads Bidding System

If your **studio manager** has requested you to set up **CPM Floor Ads Bidding** in your project, please refer to the following pages for detailed instructions:

[CPM Floor Ads Bidding](/lionsdk-1.x-legacy-docs/ads/cpm-floor-ads-bidding.md)


---

# 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/lionsdk-1.x-legacy-docs/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.
