Lion Studios
  • LionSDK Documentation
    • 📦Getting Started
    • Analytics
      • Validation
        • Event Validation
        • Lion Analytics QA Tool
        • Looker Events QA
      • A/B Testing
        • AB Test Tips (Experiment Best Practices)
      • Progression Event
      • Economy Event
      • Monetization Event
      • Advanced Ad Events
      • Interaction Events
      • Social Events
      • Debug Events
      • Other Events
      • Custom Events
      • API
        • Events
          • AbCohort
          • AppOpenShow
          • AppOpenEnd
          • AppOpenClicked
          • BannerRevenuePaid
          • BannerShowRequested
          • CharacterCreated
          • CrossPromoLoad
          • CrossPromoLoadFail
          • CrossPromoShow
          • CrossPromoStart
          • CrossPromoShowFail
          • CrossPromoEnd
          • Achievement
          • CrossPromoClick
          • DebugEvent
          • EconomyEvent
          • ErrorEvent
          • FunnelEvent
          • ShopEntered
          • Options
          • ProductViewed
          • GiftReceived
          • GiftSent
          • Heartbeat
          • ItemCollected
          • InAppPurchase
          • InterOpenStart
          • InterOpenLoadFail
          • InterOpenClicked
          • InterOpenRevenuePaid
          • InterOpenShow
          • InterOpenShowFail
          • InterOpenEnd
          • InterstitialClick
          • InterstitialEnd
          • InterstitialLoadFail
          • InterstitialLoad
          • InterstitialRevenuePaid
          • InterstitialShow
          • InterstitialShowFail
          • InterstitialStart
          • InviteReceived
          • InviteRewarded
          • InviteSent
          • GameStarted
          • FeatureUnlocked
          • NotificationOpened
          • MissionAbandoned
          • MissionCompleted
          • MissionFailed
          • MissionStarted
          • MissionStep
          • LevelAbandoned
          • LevelComplete
          • LevelFail
          • LevelStart
          • LevelStep
          • LevelUp
          • SkillUsed
          • NewPlayer
          • HandAction
          • SkillUpgraded
          • CharacterUpdated
          • PowerUpUsed
          • PredictionResult
          • RewardVideoEnd
          • RewardVideoOpportunity
          • RewardVideoClick
          • RewardVideoRevenuePaid
          • RewardVideoShow
          • RewardVideoShowFail
          • RewardVideoCollect
          • RewardVideoStart
          • Social
          • SocialConnect
          • Support
          • UiInteraction
          • ItemActioned
          • CharacterDeleted
          • AppOpenStart
          • AppOpenShowFail
          • AppOpenLoadFail
          • AppOpenLoad
          • InterOpenLoad
          • RewardVideoLoadFail
          • RewardVideoLoad
        • All Event Parameters
        • Helper Functions
        • Events Embedded
      • Experiment Events
    • Features
      • Remote Configs
        • Balancy Adapter
          • [WIP] - AB Experiments (Balancy)
        • Remote Configuration
        • Firebase
          • AB Experiments (Firebase)
        • Satori
          • A/B Experiments (Satori)
        • LiveOps Remote Config
          • Test Adapter
      • Loading Scene
      • Ads
      • IAP Validation
      • Adapter Stabilizer
      • Cloud Build
      • Options Menu
      • WhoAmI Service
    • Third-party SDKs
      • Amazon Publisher Services (APS)
      • Adjust
      • MAX SDK
        • Max Consent Flow
      • Facebook
      • Helpshift - Customer Support
    • Jenkins Build Server Solution Documentation
      • Administration of Jenkins Slack Trigger
      • Screenshare Into Jenkins Build Agents
      • Common Jenkins Build Issues
      • Jenkins Slack App Usage Guide
    • Detected Issues
      • API Level is too low
      • Publishing Settings Issue
      • Android & iOS Resolver Settings
      • SDK Settings Mismatch
      • Facebook Client Token Empty Issue
      • Adjust Id Empty Issue
Powered by GitBook
On this page
  1. LionSDK Documentation
  2. Features

Ads

PreviousLoading SceneNextIAP Validation

Last updated 1 month ago

This package simplifies showing ads from Max SDK.

It automatically handles:

  • loading the ads

  • sending required Lion Analytics Ad events

Do not call Lion Analytics’ Ad events if you use Lion Ads, or they will be sent twice.

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.

Setup

Everything should already be setup if you previously ran the 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.

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.

  • Now, if everything is setup correctly

    • Proceed to 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.IsRewardedReady

    • returns: boolean

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

    Example

    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

    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

    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.TryShowInterOpen(string placement, Action onClosed = null, Dictionary<string, object> additionalData = null)

    • returns: boolean: false if no ad was ready

    • parameters:

      • placement: a string describing this ad placement (ie: “AppOpened”…)

      • 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 InterOpenX events except _Load and _LoadFail).

    Example

    //Optional
    private Dictionary<string, object> additionalData = new Dictionary<string, object>()
    {
        { "example_key", "ExampleValue" }
    };
    
    private void ShowInterOpen()
    {
      LionAds.TryShowInterOpen("LevelStart", OnInterOpenAdClosed, additionalData);
    }
    
    //Optional
    private void OnInterOpenAdClosed()
    {
        Debug.Log("InterOpen 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

    private void ShowBanner()
    {
        LionAds.ShowBanner();
    }
  • LionAds.HideBanner()

    • returns: void

    Call this to hide the banner ad.

    Example

    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

    private void SubscribeToRewardedAdStatus()
    {
        LionAds.OnRewardedStatusChanged += (flag) =>
        {
            rewardAdButton.gameObject.SetActive(flag);
        };
    }
  • Setup
  • Code Integration