IAdsMediator

Overview

This interface describes the API for interation with any ads mediator and provides API to show ads.

Main Api

IsInitialized

bool IsInitialized { get; }

Set this field to true after the mediator has been initialized and ready for use.

OnBannerLoaded

event Action<IAdsImpression> OnBannerLoaded;

Send this event if the banner has successfully showed.Will be specific for different mediators. Must be invoked when the mediator sending revenue-data.

OnBannerLoadFailed

event Action<string> OnBannerLoadFailed;

Send this event if mediator has failed to show banner ads.

OnBannerClicked

event Action<IAdsImpression> OnBannerClicked;

Send this event if user has clicked banned ads.

IsBannerVisible

bool IsBannerVisible { get; }

Indicates whether the banner is currently showing, once the banner is hidden or the advertisement for the banner is not loaded for display the value should be false, if the banner is successfully displayed the value should be true.

ShowBanner

void ShowBanner();

Method should set true to the IsBannerVisible property and show the banner.

HideBanner

void HideBanner();

Method should hide the banner and immediately set false to the IsBannerVisible property.

Reward

OnRewardShown

event Action<IAdsImpression> OnRewardShown;

Must be invoked when rewarded ad successfully shown. Will be specific for different mediators. Must be invoked when the mediator sending revenue-data.

OnRewardLoaded

event Action OnRewardLoaded;

Send this event when the ad is loaded and set the IsRewardedVideoReady field to true.

OnRewardLoadFailed

event Action<string> OnRewardLoadFailed;

Send this event in case of errors during video loading and pass an argument to the error message.

OnRewardDisplayFailed

event Action<string> OnRewardDisplayFailed;

Send this event if the ad fails, passing an error message as an argument.

OnRewardReceived

event Action OnRewardReceived;

Send this event in the case of a successful showing of a reward in which the player should receive a reward.

OnRewardClicked

event Action<IAdsImpression> OnRewardClicked;

Send this event if user has clicked rewarded ads.

OnRewardHidden

event Action<IAdsImpression> OnRewardHidden;

Send this event immediately after the rewatch is finished and the player returns to the game (regardless of whether he receives the reward or not), pass information about the advertisement that was shown to player packed in IAdsImpression.

IsRewardedVideoReady

bool IsRewardedVideoReady { get; }

This property indicates whether the ad is ready to be displayed. Advertiser accesses this property before loading and displaying ads to check if the ad needs to be loaded or if it is ready to be displayed.

LoadRewardVideo

void LoadRewardVideo();

Method should load ads for future display.

ShowRewardVideo

void ShowRewardVideo(string placement);

Method should show the loaded advertisement.

Interstitial

OnInterShown

event Action<IAdsImpression> OnInterShown;

Must be invoked when interstitial ad successfully shown. Will be specific for different mediators. Must be invoked when the mediator sending revenue-data.

OnInterLoaded

event Action OnInterLoaded;

Send this event when the ad is loaded and set the IsInterVideoReady field to true.

OnInterLoadFailed

event Action<string> OnInterLoadFailed;

Send this event if the ad fails to load and set the value to false in the IsInterVideoReady field. Pass an error message in the argument.

OnInterDisplayFailed

event Action<string> OnInterDisplayFailed;

Send this event if the ad fails, passing an error message as an argument.

OnInterClicked

event Action<IAdsImpression> OnInterClicked;

Send this event if user has clicked interstitial ads.

OnInterHidden

event Action<IAdsImpression> OnInterHidden;

Send this event after the player views the inter and returns back to the game (regardless of whether the player clicked on the inter or not), pass information about the advertisement that was shown to player packed in IAdsImpression.

IsInterVideoReady

bool IsInterVideoReady { get; }

This property indicates whether the ad is ready to be displayed. Advertiser refers to it before loading and displaying ads to check whether it is necessary to load the ad or it is ready for displaying.

LoadInterVideo

void LoadInterVideo();

Method should load ads for future display.

ShowInterVideo

void ShowInterVideo(string placement);

The method should show the loaded advertisement.

Loaded ad price

GetLoadedPricePoint

AdPricePoint? GetLoadedPricePoint(string adUnitId);

Returns the price of the rewarded or interstitial ad that is loaded for the ad unit and ready to be shown, for example to compare Revenue with your floor price before showing it.

  • Returns null when no ad of the ad unit is ready to be shown, including an ad that has already been shown.
  • MaxMediator reports any rewarded or interstitial ad unit loaded through MAX, including the ad units your app loads itself. LevelPlayMediator reports only the ad units set in MagifySettings.
  • Call it on the main thread, in OnRewardLoaded / OnInterLoaded of the mediator or later.
  • The method has a default implementation returning null, so your own mediator does not have to implement it.

AdPricePoint:

  • Revenue — revenue of one impression in USD, null when the ad network reported no valid price.
  • Precision — where Revenue comes from: Exact (a real-time auction), Estimated (an estimate of the ad network), PublisherDefined (the CPM you set in the MAX or LevelPlay dashboard), Undisclosed (the ad network does not share the price, Revenue is null) or Unknown (no precision reported).

Example:

var floorCpm = 5d; // USD per 1000 impressions
var price = MagifyService.Instance.Advertiser.Mediator?.GetLoadedPricePoint(rewardAdUnitId);
if (price?.Revenue * 1000 >= floorCpm)
{
    // show the ad
}

Related articles

ICampaign

Android SDK Initialization

Flutter SDK Configuration options

Magify Service

Flutter SDK Installation

Introduction