High Value Ads

Table of Contents

Introduction

If properly configured in Homa Lab, you’ll be able to use the High Value Ads API.

ℹ️ High Value ads are just like regular ads, but have a different ad waterfall / ad network configurations. High value ads are usually shown when giving a bigger reward to the player.

Enabling High Value Ads

Homa Belly does not automatically load High Value Ads, so make sure to invoke: HomaBelly.Instance.LoadHighValueRewardedVideoAd and/or HomaBelly.Instance.LoadHighValueInterstitial to enable the feature for each type of ad.

ℹ️ Once High Value Ads are loaded the first time, Homa Belly will automatically take care of reloading when failed/shown, so you do not need to care about it.


// Loads a high value interstitial ad, will do nothing if no 
/// high value ad is configured in the manifest.
HomaBelly.Instance.LoadHighValueInterstitial();

// Loads a high value rewarded ad, will do nothing if no high value ad is 
/// configured in the manifest.
HomaBelly.Instance.LoadHighValueRewardedVideoAd();

Checking if High Value Ads are available

Once load has been requested, if you want to determine if a High Value Ad is available to be shown, you can do that by:


/// <summary>
/// Determines if the default high value interstitial ad is available
/// </summary>
HomaBelly.Instance.IsHighValueInterstitialAvailable();

/// <summary>
/// Determines if the default high value rewarded video ad is available
/// </summary>
HomaBelly.Instance.IsHighValueRewardedVideoAdAvailable();

Showing High Value Interstitials


/// Requests to show a high value interstitial ad
HomaBelly.Instance.ShowHighValueInterstitial("your_analytics_human_readable_ad_name");

Showing High Value Rewarded Videos


/// Requests to show a high value rewarded video ad
HomaBelly.Instance.ShowHighValueRewardedVideoAd("your_analytics_human_readable_ad_name");

Listening to High Value Ad Callbacks

High Value Ads will invoke usual Homa Belly Advertising callbacks like onInterstitialAdShowSucceededEvent or onRewardedVideoAdRewardedEvent, for example.

Those callbacks do receive an AdInfo object with a few properties, AdPlacementType among others. This property can be:

  • HighValue: if the ad triggering the callback is a High Value Ad
  • Default: if the ad triggering the callback is a Default Ad
  • User: if the ad triggering the callback is a user specified ad (custom ad unit id)

Hence, you can act consequently if the player saw a High Value Ad or not:

// Interstitial
Events.onInterstitialAdShowSucceededEvent += (adInfo) =>
{
    if(adInfo.AdPlacementType == AdPlacementType.HighValue)
    {
        // Grant a big reward to the user if desired
    }
    else if (adInfo.AdPlacementType == AdPlacementType.Default)
    {
        // Grant a default reward to the user
    }
};

// Rewarded Video
Events.onRewardedVideoAdRewardedEvent += (reward,adInfo) =>
{
    if(adInfo.AdPlacementType == AdPlacementType.HighValue)
    {
        // Grant a big reward to the user if desired
    }
    else if (adInfo.AdPlacementType == AdPlacementType.Default)
    {
        // Grant a default reward to the user
    }
};

// Rewarded Video Failed
Events.onRewardedVideoAdShowFailedEvent += (reward,adInfo) =>
{
    if(adInfo.AdPlacementType == AdPlacementType.HighValue)
    {
        // High Value failed to show. Do nothing
    }
    else if (adInfo.AdPlacementType == AdPlacementType.Default)
    {
        // Default rewarded failed to show
    }
};

Usage example: show High Value Ads at default placements if available

Assuming you have an AdsManager script initialized after Homa Belly, make sure you invoke LoadHighValueInterstitial and LoadHighValueRewardedVideoAd methods on Awake and try to show a High Value Ad every time your game should show an advertisement (see TryShowInterstitial and TryShowRewardedVideo)


using System;
using System.Collections;
using HomaGames.HomaBelly;
using UnityEngine;

/// This script will show High Value Ads if available
/// otherwise it will show default ads
public class AdsManager : MonoBehavior
{
    private void Awake()
    {
        // Ensure to invoke LoadHighValue ads after Homa Belly is fully initialized
        if (!HomaBelly.Instance.IsInitialized)
        {
            Events.onInitialized += () =>
            {
                HomaBelly.Instance.LoadHighValueRewardedVideoAd();
                HomaBelly.Instance.LoadHighValueInterstitial();
            };
        }
        else
        {
            HomaBelly.Instance.LoadHighValueRewardedVideoAd();
            HomaBelly.Instance.LoadHighValueInterstitial();
        }
    }

    public void TryShowInterstitial(string placementName)
    {
				// If High Value Interstitial is available, show it
        if (HomaBelly.Instance.IsHighValueInterstitialAvailable())
            HomaBelly.Instance.ShowHighValueInterstitial(placementName);
        else
            HomaBelly.Instance.ShowInterstitial(placementName);
    }

    public void TryShowRewardedVideo(string placementName)
    {
				// If High Value Rewarded Video is available, show it
        if (HomaBelly.Instance.IsHighValueRewardedVideoAdAvailable())
            HomaBelly.Instance.ShowHighValueRewardedVideoAd(placementName);
        else
            HomaBelly.Instance.ShowRewardedVideoAd(placementName);
    }
}