Skip to main content
Version: 6.x.x

Rewarded Ad

note

In v6.0.0 the class was renamed from RewardedVideoAd to RewardedAd.

Integration​

Step 1. Instantiate Rewarded Ad​

You can instantiate a RewardedAd right after the SDK finishes initialization. Pass the platform-specific rewarded placement id to the RewardedAd constructor.

public class BlueStackAdsController : MonoBehaviour
{
private RewardedAd _rewardedAd;

void Start()
{
BlueStackAds.SetDebugMode(true);
BlueStackAds.Initialize("app_id", HandleInitCompleteAction);
}

private void HandleInitCompleteAction(InitializationStatus status)
{
_rewardedAd = new RewardedAd(placementId);
}
}

Step 2. Register event listeners​

RewardedAd exposes the following events through its lifecycle.

EventPayloadDefinition
OnAdLoadedEventArgsAd finished loading and is ready to be shown.
OnAdFailedToLoadBlueStackErrorThe ad failed to load.
OnAdDisplayedEventArgsThe ad has appeared on screen.
OnAdFailedToDisplayBlueStackErrorThe ad failed to display after Show() was called.
OnAdClickedEventArgsThe user clicked the ad.
OnAdRewardEarnedRewardedItemThe user earned a reward (typically after watching the video to completion). The payload's Amount and Type may be unset depending on the mediation network.
OnAdDismissedEventArgsThe user dismissed the ad. Fired whether or not a reward was earned.
_rewardedAd.OnAdLoaded += (sender, args) =>
{
Debug.Log("OnAdLoaded");
};

_rewardedAd.OnAdFailedToLoad += (sender, error) =>
{
Debug.LogError("OnAdFailedToLoad: " + error.Message);
};

_rewardedAd.OnAdDisplayed += (sender, args) =>
{
Debug.Log("OnAdDisplayed");
};

_rewardedAd.OnAdFailedToDisplay += (sender, error) =>
{
Debug.LogError("OnAdFailedToDisplay: " + error.Message);
};

_rewardedAd.OnAdClicked += (sender, args) =>
{
Debug.Log("OnAdClicked");
};

_rewardedAd.OnAdRewardEarned += (sender, reward) =>
{
Debug.Log("OnAdRewardEarned reward: '" + reward?.Type + "', amount: " + reward?.Amount);
};

_rewardedAd.OnAdDismissed += (sender, args) =>
{
Debug.Log("OnAdDismissed");
};
caution

Make sure you only register event listeners once.

Step 3. Load Rewarded ad​

RewardedAd exposes two Load overloads; one parameterless, and one taking a RequestOptions instance for audience targeting.

info

There must be a delay of at least 5 seconds between each rewarded ad Load call.

  • Without targeting
_rewardedAd.Load();
  • With targeting
var requestOptions = new RequestOptions(
age: 25,
gender: Gender.Male,
location: new Location(35.757866, 10.810547, Location.GPS_PROVIDER),
consentFlag: 1,
language: "en",
keyword: "brand=myBrand;category=sport",
contentUrl: "https://console.bluestack.app");

_rewardedAd.Load(requestOptions);

RequestOptions is immutable and reusable across Load calls. See Targeting Audiences for the full field reference and consent-flag semantics.

Step 4. Display Rewarded ad​

After the ad has loaded, request it to be displayed. Check IsReady to confirm the ad is loaded before calling Show().

if (_rewardedAd.IsReady)
{
_rewardedAd.Show();
}

Equivalently, gate on OnAdLoaded:

_rewardedAd.OnAdLoaded += (sender, args) =>
{
_rewardedAd.Show();
};

Destroy Rewarded ad​

Destroy the rewarded ad before creating a new one.

_rewardedAd.Destroy();