Displaying Ads

Displaying an Interstitial Ad

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.

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

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

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.

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

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

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

  • 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: By default, banners are shown as soon as they finish loading. Enable this if you want to control when the banner is shown manually.

Show Banner

LionAds.ShowBanner();

Hide Banner

LionAds.HideBanner();

Last updated

Was this helpful?