The MVP Unity Developer Hub

Welcome to the MVP Unity developer hub. You'll find comprehensive guides and documentation to help you start working with MVP Unity as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

Rewarded Ads

Introduction

Rewarded ads are an engaging ad format that shows a short video ad to the user and in exchange the user will earn a reward. The user must consent and watch the video completely through to the end in order to earn the reward.

Important

The speed and stability of users internet connections may vary. It is highly recommended to fetch as far in advance of showing an ad as possible. This helps to ensure that all necessary assets are downloaded. For example, you may want to fetch an ad when a level starts, or after a previous ad has been shown.

Make an Ad Request

The following example shows how to make a request to display the Rewarded ads.

string placementId = "1234";

Rewarded.Request(placementId);

Adding Callbacks

The callback code below is required for SDK to properly track the activity of your ad

public class MyRewardedListener : RewardedListener
{
    public void OnShow(string placementId, ImpressionData impressionData)
    {
        // Called when a rewarded ad from placementId shows up. In case the ad is a video, audio play will start here.
        // On Android, this callback might be called only once the ad is closed.
    }

    public void OnClick(string placementId)
    {
        // Called when a rewarded ad from placement 'placementId' is clicked
    }

    public void OnHide(string placementId)
    {
        // Called when a rewarded ad from placement 'placementId' hides. 
    }

    public void OnShowFailure(string placementId, ImpressionData impressionData)
    {
        // Called when an error arises when showing a rewarded ad from placement 'placementId'
    }

    public void OnAvailable(string placementId)
    {
        // Called when a rewarded ad from placement 'placementId' becomes available
    }

    public void OnUnavailable(string placementId)
    {
        // Called when a rewarded ad from placement 'placementId' becomes unavailable
    }

    public void OnCompletion(string placementId, bool userRewarded)
    {
        // Called when a rewarded ad from placement 'placementId' finishes playing. In case the ad is a video, audio play will stop here.
    }

    public void OnRequestStart(string placementId)
    {
        // Called when a rewarded ad from placement 'placementId' is going to be requested
    }
}


Rewarded.SetRewardedListener(new MyRewardedListener());

Example showing an ad

The following example checks to see if a is available and if it is, uses the show request to display the ad.

If your game needs to be paused before showing an ad (e.g., stop audio playback), this is the best moment to do so.
The time between calling this API and the ad actually being shown should be negligible.
This approached is preferable compared to relying on the 'OnShow' callback since on Android, we cannot guarantee it will be called before the ad starts playing.

string placementId = "1234";

if (Rewarded.IsAvailable(placementId)) {
	Dictionary<string, string> pubParams = new Dictionary<string, string>();
	RewardedOptions rewardedOptions = new RewardedOptions(pubParams);

	Rewarded.Show(placementId, rewardedOptions);
}

Stop Requesting An Ad

In case a placement is no longer relevant for your user, you can stop requesting it.

string placementId = "1234";

Rewarded.StopRequesting(placementId);

Important

Use stopRequesting to disable the FairBid SDK Auto-Request functionality for a specific placement. If you continue requesting ads for placements that are not shown, the performance of your placement can be impacted.

Server Side Rewarding

For details on configuring Server Side Rewarding, click here.


Rewarded Ads


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.