Using MCSDK, you can load multiple ad placements of mediation SDKs at the same time, and give priority to the ad slot with the highest price among these successfully loaded ad placements when the ad is displayed.
Note
In order to reduce access costs, the API of the SDK is provided based on Max, but there will still be differences. For details, please refer to the document description below.
You can use max ad units for loading and display, but you must add a global configuration JSON file to map max ad units, etc., so that the sdk can work properly.
Please contact us to obtain sdk
Take the following steps to import the plugin you downloaded:
In Unity, select Assets > Import Package > Custom Package…
Choose the Unity Plugin file you downloaded.
In the Import Unity Package dialog, click Import.
Either Unity 5.x.x, or Unity 2017.x.x or later. (For Admob, you need to use Unity 2022.3.x or later)
For Android builds, the plugin requires that you enable Jetifier. To enable Jetifier, take the following steps:
For Android builds, the plugin requires that you generate template gradle files. To generate files, take the following steps:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application android:label="@string/app_name">
<!--Admob APPLICATION_ID start-->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="<your admob application id>" />
<!--Admob APPLICATION_ID end-->
</application>
</manifest>
Call all APIs on the main thread.
Note: mcRes.androidlib below is the name of the folder directory (must include the ".androidlib" suffix)
Create the AndroidManifest.xml file in the Assets/Plugins/Android/mcRes.androidlib directory with the following content:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mcsdk.unity.res">
</manifest>
Create the MCGlobalConfig.json file in the Assets/Plugins/Android/mcRes.androidlib/assets/LocalConfig directory
Create the MCGlobalConfig.json file in the Assets/Plugins/Android/res/xml directory
The configuration example of MCGlobalConfig.json is as follows:
{
"init_timeout": <init_timeout_ms>,
"init_params": {
"max": {
"sdk_key": <max_sdk_key>
},
"topon": {
"app_id": <topon_app_id>,
"app_key": <topon_app_key>
}
},
"pl_info": [
{
"max": <max_ad_unit_id>,
"topon": <topon_placement_id>,
"format": "rewarded"
},
{
"max": <max_ad_unit_id>,
"topon": <topon_placement_id>,
"format": "interstitial"
},
...
]
}
Key description in JSON:
Key | Value | Description | Note |
---|---|---|---|
init_timeout | int | init timeout, unit: ms | (optional) default: 5000ms |
init_params | json object | Each mediation SDK initialization parameters | (required) MCSDK initializes Max SDK and TopOn SDK according to this configuration |
pl_info | json array | The mapping relationship between each advertising placement |
(required) MCSDK loads and displays ads from Max SDK and TopOn SDK based on this configuration. When there are multiple advertising slots, they need to be configured in this json array |
init_params:
Key | Value | Description | Note |
---|---|---|---|
init_params.max.sdk_key | string | Max's sdk key | (required) |
init_params.topon.app_id | string | TopOn's app id | (required) |
init_params.topon.app_key | string | TopOn's app key | (required) |
pl_info:
Key | Value | Description | Note |
---|---|---|---|
pl_info.max | string | Max's ad Unit Id | (required) |
pl_info.topon | string | TopOn’s advertising placement ID | (optional) When TopOn advertising placements need to be loaded together, configuration is required for price comparison display. |
pl_info.topon_adx | string | TopOn Adx’s advertising placementID | (optional) When TopOn Adx advertising placements need to be loaded together, configuration is required for price comparison display. |
pl_info.format | - | ad format | (optional) The format is only used to identify this group of ad slots. MCSDK will not use this field. |
Attach the OnSdkInitializedEvent
event handler, then set the SDK key and initialize the SDK as soon as your app launches, as in the following code sample.
McSdkCallbacks.OnSdkInitializedEvent += (McSdkBase.SdkConfiguration sdkConfiguration) => {
// SDK is initialized, start loading ads
};
McSdk.SetUserId("USER_ID");
McSdk.InitializeSdk();
The following code shows you how to attach listeners and load the first rewarded ad:
string adUnitId = "YOUR_MAX_AD_UNIT_ID";
int retryAttempt;
public void InitializeRewardedAds()
{
// Attach callbacks
McSdkCallbacks.Rewarded.OnAdLoadedEvent += OnRewardedAdLoadedEvent;
McSdkCallbacks.Rewarded.OnAdLoadFailedEvent += OnRewardedAdFailedEvent;
McSdkCallbacks.Rewarded.OnAdDisplayFailedEvent += OnRewardedAdFailedToDisplayEvent;
McSdkCallbacks.Rewarded.OnAdDisplayedEvent += OnRewardedAdDisplayedEvent;
McSdkCallbacks.Rewarded.OnAdClickedEvent += OnRewardedAdClickedEvent;
McSdkCallbacks.Rewarded.OnAdHiddenEvent += OnRewardedAdDismissedEvent;
McSdkCallbacks.Rewarded.OnAdReceivedRewardEvent += OnRewardedAdReceivedRewardEvent;
McSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnRewardedAdRevenuePaidEvent;
// Load the first rewarded ad
LoadRewardedAd();
}
private void LoadRewardedAd()
{
McSdk.LoadRewardedAd(adUnitId);
}
private void OnRewardedAdLoadedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Rewarded ad is ready for you to show. McSdk.IsRewardedAdReady(adUnitId) now returns 'true'.
// Reset retry attempt
retryAttempt = 0;
}
private void OnRewardedAdLoadFailedEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo)
{
// Rewarded ad failed to load
// recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds).
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadRewardedAd", (float) retryDelay);
}
private void OnRewardedAdDisplayedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnRewardedAdFailedToDisplayEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo, McSdkBase.AdInfo adInfo)
{
// Rewarded ad failed to display. Recommends that you load the next ad.
LoadRewardedAd();
}
private void OnRewardedAdClickedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnRewardedAdHiddenEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Rewarded ad is hidden. Pre-load the next ad
LoadRewardedAd();
}
private void OnRewardedAdReceivedRewardEvent(string adUnitId, McSdk.Reward reward, McSdkBase.AdInfo adInfo)
{
// The rewarded ad displayed and the user should receive the reward.
}
private void OnRewardedAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Ad revenue paid. Use this callback to track user revenue.
}
To show a rewarded ad, call ShowRewardedAd()
:
if (McSdk.IsRewardedAdReady(adUnitId))
{
McSdk.ShowRewardedAd(adUnitId);
}
To access the reward amount and currency, override the OnRewardedAdReceivedRewardEvent
callback:
private void OnRewardedAdReceivedRewardEvent(string adUnitId, McSdk.Reward reward, McSdkBase.AdInfo adInfo)
{
print("Rewarded user: " + reward.Amount + " " + reward.Label);
}
The following code shows you how to attach listeners and load the first interstitial:
string adUnitId = "YOUR_MAX_AD_UNIT_ID";
public void InitializeInterstitialAds()
{
// Attach callback
McSdkCallbacks.Interstitial.OnAdLoadedEvent += OnInterstitialLoadedEvent;
McSdkCallbacks.Interstitial.OnAdLoadFailedEvent += OnInterstitialLoadFailedEvent;
McSdkCallbacks.Interstitial.OnAdDisplayedEvent += OnInterstitialDisplayedEvent;
McSdkCallbacks.Interstitial.OnAdClickedEvent += OnInterstitialClickedEvent;
McSdkCallbacks.Interstitial.OnAdHiddenEvent += OnInterstitialHiddenEvent;
McSdkCallbacks.Interstitial.OnAdDisplayFailedEvent += OnInterstitialAdFailedToDisplayEvent;
McSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnInterstitialRevenuePaidEvent;
// Load the first interstitial
LoadInterstitial();
}
private void LoadInterstitial()
{
McSdk.LoadInterstitial(adUnitId);
}
private void OnInterstitialLoadedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Interstitial ad is ready for you to show. McSdk.IsInterstitialReady(adUnitId) now returns 'true'
// Reset retry attempt
retryAttempt = 0;
}
private void OnInterstitialLoadFailedEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo)
{
// Interstitial ad failed to load
// Recommends that you retry with exponentially higher delays, up to a maximum delay (in this case 64 seconds)
retryAttempt++;
double retryDelay = Math.Pow(2, Math.Min(6, retryAttempt));
Invoke("LoadInterstitial", (float) retryDelay);
}
private void OnInterstitialDisplayedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnInterstitialAdFailedToDisplayEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo, McSdkBase.AdInfo adInfo)
{
// Interstitial ad failed to display. Recommends that you load the next ad.
LoadInterstitial();
}
private void OnInterstitialClickedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnInterstitialHiddenEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Interstitial ad is hidden. Pre-load the next ad.
LoadInterstitial();
}
private void OnInterstitialRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// Ad revenue paid. Use this callback to track user revenue.
}
To show an interstitial ad, call ShowInterstitial()
:
if ( McSdk.IsInterstitialReady(adUnitId) )
{
McSdk.ShowInterstitial(adUnitId);
}
The following code shows you how to attach listeners and load the first app open ad:
string adUnitId = "YOUR_MAX_AD_UNIT_ID";
private void InitializeAppOpenAds()
{
// Attach callbacks
McSdkCallbacks.AppOpen.OnAdLoadedEvent += OnAppOpenAdLoadedEvent;
McSdkCallbacks.AppOpen.OnAdLoadFailedEvent += OnAppOpenAdFailedEvent;
McSdkCallbacks.AppOpen.OnAdDisplayFailedEvent += OnAppOpenAdFailedToDisplayEvent;
McSdkCallbacks.AppOpen.OnAdDisplayedEvent += OnAppOpenAdDisplayedEvent;
McSdkCallbacks.AppOpen.OnAdClickedEvent += OnAppOpenAdClickedEvent;
McSdkCallbacks.AppOpen.OnAdHiddenEvent += OnAppOpenAdDismissedEvent;
McSdkCallbacks.AppOpen.OnAdRevenuePaidEvent += OnAppOpenAdRevenuePaidEvent;
// Load the first AppOpenAd
LoadAppOpenAd();
}
private void LoadAppOpenAd()
{
McSdk.LoadAppOpenAd(adUnitId);
}
private void OnAppOpenAdLoadedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// App open ad is ready to be shown. McSdk.IsAppOpenAdReady(AppOpenAdUnitId) will now return 'true'
}
private void OnAppOpenAdFailedEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo)
{
// App open ad failed to load.
}
private void OnAppOpenAdFailedToDisplayEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo, McSdkBase.AdInfo adInfo)
{
// App open ad failed to display.
}
private void OnAppOpenAdDisplayedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
}
private void OnAppOpenAdClickedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
}
private void OnAppOpenAdDismissedEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// App open ad is hidden.
}
private void OnAppOpenAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
// App open ad revenue paid. Use this callback to track user revenue.
}
To show an app open ad, call ShowAppOpenAd()
:
if ( McSdk.IsAppOpenAdReady(adUnitId) )
{
McSdk.ShowAppOpenAd(adUnitId);
}
To load a banner, call the following using your Ad Unit ID and desired banner position:
string bannerAdUnitId = "YOUR_MAX_AD_UNIT_ID"; // Retrieve the ID from your account
public void InitializeBannerAds()
{
// Banners are automatically sized to 320×50 on phones and 728×90 on tablets
// You may call the utility method McSdkUtils.isTablet() to help with view sizing adjustments
McSdk.CreateBanner(bannerAdUnitId, McSdkBase.BannerPosition.BottomCenter);
// Set background or background color for banners to be fully functional
McSdk.SetBannerBackgroundColor(bannerAdUnitId, );
McSdkCallbacks.Banner.OnAdLoadedEvent += OnBannerAdLoadedEvent;
McSdkCallbacks.Banner.OnAdLoadFailedEvent += OnBannerAdLoadFailedEvent;
McSdkCallbacks.Banner.OnAdClickedEvent += OnBannerAdClickedEvent;
McSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnBannerAdRevenuePaidEvent;
McSdkCallbacks.Banner.OnAdDisplayedEvent += OnBannerAdDisplayedEvent;
McSdkCallbacks.Banner.OnAdExpandedEvent += OnBannerAdExpandedEvent;
McSdkCallbacks.Banner.OnAdCollapsedEvent += OnBannerAdCollapsedEvent;
}
private void OnBannerAdLoadedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnBannerAdLoadFailedEvent(string adUnitId, McSdkBase.ErrorInfo errorInfo) {}
private void OnBannerAdClickedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnBannerAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnBannerAdDisplayedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnBannerAdExpandedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
private void OnBannerAdCollapsedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
Set your banner background color to a #-prefixed hexadecimal RGB string, for example '#000000'
(black) or '#fff200'
(yellow).:The above example creates a banner at the bottom-center of the display (BottomCenter
). The complete list of position options are:
TopLeft
TopCenter
TopRight
Centered
CenterLeft
CenterRight
BottomLeft
BottomCenter
BottomRight
You can also position a banner ad at a specific (x, y) coordinate on the screen by calling McSdk.CreateBanner(ad-unit-ID, x, y);
. This sets the position of the top-left corner of the ad. The coordinate system represents the safe area bounds of the screen. Make sure to account for the width and height of the ad when you set these coordinates. The position (0, 0) is equivalent to TopLeft
; the bottom-right corner of the safe area is (safeAreaWidth, safeAreaHeight). Note that Unity might have a different screen size or safe area size than Android or iOS. To convert between Unity’s screen size and the sizes used in Android, use code like the following:
var density = McSdkUtils.GetScreenDensity();
var dp = pixels / density;
To show a banner, call ShowBanner()
:
McSdk.ShowBanner(bannerAdUnitId);
To hide a banner, call HideBanner()
:
McSdk.HideBanner(bannerAdUnitId);
After you are no longer using a banner instance (for example, if the user purchased ad removal), call the DestroyBanner()
method to free resources. Do not call DestroyBanner()
if you use multiple banner instances with the same Ad Unit ID.
McSdk.DestroyBanner(bannerAdUnitId);
To get the banner’s position and size, call GetBannerLayout()
. This uses the same Unity coordinate system as explained in Loading a Banner.
Rect bannerLayout = McSdk.GetBannerLayout(bannerAdUnitId);
To manually set the banner’s width, call SetBannerWidth()
. Be sure to set the banner width to a size larger than the minimum value (320 on phones, 728 on tablets). Banners under this width may not be considered viewable by the advertiser, and this will affect your revenue:
McSdk.SetBannerWidth(bannerAdUnitId, width);
MCSDK does not support automatic refresh of banners. It is recommended that developers call the following code after a certain interval of time after the banner is displayed and reinitiate load. If it is not reinitiated, the banner will always display ads for a certain Mediation.
McSdk.StopBannerAutoRefresh(bannerAdUnitId);
McSdk.LoadBanner(bannerAdUnitId);
Note:
There may be cases when you would like to stop auto-refresh, for instance, if you want to manually refresh banner ads. To stop auto-refresh for a banner ad, use the following code:
McSdk.StopBannerAutoRefresh(bannerAdUnitId);
Start auto-refresh for a banner ad with the following code:
McSdk.StartBannerAutoRefresh(bannerAdUnitId);
To load an MREC, call CreateMRec()
, passing in your ad unit ID and desired adview position:
string mrecAdUnitId = "YOUR_MAX_AD_UNIT_ID"; // Retrieve the ID from your account
public void InitializeMRecAds()
{
// MRECs are sized to 300x250 on phones and tablets
McSdk.CreateMRec(mrecAdUnitId, McSdkBase.AdViewPosition.Centered);
McSdkCallbacks.MRec.OnAdLoadedEvent += OnMRecAdLoadedEvent;
McSdkCallbacks.MRec.OnAdLoadFailedEvent += OnMRecAdLoadFailedEvent;
McSdkCallbacks.MRec.OnAdClickedEvent += OnMRecAdClickedEvent;
McSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnMRecAdRevenuePaidEvent;
McSdkCallbacks.MRec.OnAdDisplayedEvent += OnMRecAdDisplayedEvent;
McSdkCallbacks.MRec.OnAdExpandedEvent += OnMRecAdExpandedEvent;
McSdkCallbacks.MRec.OnAdCollapsedEvent += OnMRecAdCollapsedEvent;
}
public void OnMRecAdLoadedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
public void OnMRecAdLoadFailedEvent(string adUnitId, McSdkBase.ErrorInfo error) {}
public void OnMRecAdClickedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
public void OnMRecAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
public void OnMRecAdDisplayedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
public void OnMRecAdExpandedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
public void OnMRecAdCollapsedEvent(string adUnitId, McSdkBase.AdInfo adInfo) {}
The above example creates an MREC centered on the display ( Centered
). The complete list of position options are:
TopLeft
TopCenter
TopRight
CenterLeft
Centered
CenterRight
BottomLeft
BottomCenter
BottomRight
You can also position an MREC at a specific (x, y) coordinate on the screen by calling McSdk.CreateMRec(ad-unit-ID, x, y);
. This sets the position of the top-left corner of the ad. The coordinate system represents the safe area bounds of the screen. Make sure to account for the width and height of the ad when you set these coordinates. The position (0, 0) is equivalent to TopLeft
; the bottom-right corner of the safe area is (safeAreaWidth, safeAreaHeight). Note that Unity might have a different screen size or safe area size than Android or iOS. To convert between Unity’s screen size and the sizes used in Android, use code like the following:
var density = McSdkUtils.GetScreenDensity();
var dp = pixels / density;
To show an MREC ad, call ShowMRec()
:
McSdk.ShowMRec(mrecAdUnitId);
To hide an MREC ad, call HideMRec()
:
McSdk.HideMRec(mrecAdUnitId);
After you are no longer using the MREC instance (for example, if the user purchased ad removal), call the DestroyMRec()
method to free resources. Do not call DestroyMRec()
if you use multiple MREC instances with the same Ad Unit ID.
McSdk.DestroyMRec(mrecAdUnitId);
MCSDK does not support automatic refresh of mrecs. It is recommended that developers call the following code after a certain interval of time after the MREC ad is displayed and reinitiate load. If it is not reinitiated, the MREC ad will always display ads for a certain Mediation.
McSdk.StopMRecAutoRefresh(mrecAdUnitId);
McSdk.LoadMRec(mrecAdUnitId);
Note:
There may be cases when you would like to stop auto-refresh, for instance, if you want to manually refresh MREC ads. To stop auto-refresh for an MREC ad, use the following code:
McSdk.StopMRecAutoRefresh(mrecAdUnitId);
Start auto-refresh for an MREC ad with the following code:
McSdk.StartMRecAutoRefresh(mrecAdUnitId);
Turn on the log switch of MCSDK
McSdk.SetVerboseLogging(true);
In Android Studio's Logcat, you can view related logs through this TAG: mcsdk|Unity
After initializing MCSDK, you can choose to call the following code to open the Max or TopOn Mediation Debugger respectively.
Max Mediation Debugger:
McSdk.ShowMediationDebugger(McSdkBase.MediationId.Max);
For more information, please refer to: Max Mediation Debugger
TopOn Mediation Debugger:
McSdk.ShowMediationDebugger(McSdkBase.MediationId.TopOn);
For more information, please refer to: TopOn Mediation Debugger
Your ad display delegate or callback interface will receive a call if an ad failed to load or failed to display. This call will be accompanied by an error code. This page describes the error codes you may see.
The error that you receive in your callback is a first-class error object that implements ErrorInfo
. This object has the following APIs:
Code
|
Enum
|
Description
|
Load / Display
|
---|---|---|---|
−1
|
McSdkBase.ErrorCode.Unspecified
|
The system is in an unexpected state. This error code represents an error that could not be categorized into one of the other defined errors. See the message field in the error object for more details.
|
L/D
|
-5202
|
McSdkBase.ErrorCode.InvalidConfiguration
|
The parameters passed in to sdk are invalid and need to be checked.
|
L
|
−5001
|
McSdkBase.ErrorCode.AdLoadFailed
|
The ad failed to load due to no networks being able to fill. MCSDK returned eligible ads from mediated networks, but all ads failed to load. See the adLoadFailureInfo field in the error object for more details.
|
L
|
−5601
|
McSdkBase.ErrorCode.NoActivity
|
The SDK failed to load an ad because it could not find the top Activity.
|
L
|
If the user consents to interest-based advertising, set the user consent flag to true by calling SetHasUserConsent, and start requesting ads through the MCSDK. After you set the consent value to true for a particular user, MCSDK will continue to respect that value for the lifetime of your application or until the user revokes consent to interest-based advertising.
McSdk.SetHasUserConsent(true);
If the user does not consent to interest-based advertising, set the user consent flag to false by calling SetHasUserConsent for a particular user, and start requesting ads through the MCSDK. After you set the consent value to false, MCSDK will continue to respect that value for the lifetime of your application or until the user consents to interest-based advertising.
McSdk.SetHasUserConsent(false);
Note: The following API is not valid for topon. For topon, please go to App page ,then click "edit" button to set up
If you know that the user falls within an age-restricted category (i.e., under the age of 16, or as otherwise defined by applicable laws), you must set the age-restricted user flag to true.
McSdk.SetIsAgeRestrictedUser(true);
If you know that the user does not fall within an age-restricted category (i.e., age 16 or older, or as otherwise defined by applicable laws), you must set the age-restricted user flag to false.
McSdk.SetIsAgeRestrictedUser(false);
Note: The following API is not valid for topon. For topon, please go to App page ,then click "edit" button to set up
State laws in the United States may require you to display a “Do Not Sell or Share My Personal Information” link or provide other options to users located in those states to opt out of interest-based advertising. You must set a flag that indicates whether users in the relevant states opt out of interest-based advertising or the sale or share of personal information for interest-based advertising.
If a user does not opt out in these ways, set the do-not-sell flag to false.
McSdk.SetDoNotSell(false);
If a user does opt out in these ways, set the do-not-sell flag to true.
McSdk.SetDoNotSell(true);
The following example shows how to do this within the “ad revenue paid” callback:
// Attach callbacks based on the ad format(s) you are using
McSdkCallbacks.Interstitial.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
McSdkCallbacks.Rewarded.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
McSdkCallbacks.AppOpen.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
McSdkCallbacks.Banner.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
McSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnAdRevenuePaidEvent;
⋮
private void OnAdRevenuePaidEvent(string adUnitId, McSdkBase.AdInfo adInfo)
{
double revenue = adInfo.Revenue;
// Miscellaneous data
MediationId mediationId = adInfo.MediationId; // The mediation ID that showed the ad (1: "TopOn", 2: "Max")
string mediationPlacementId= adInfo.MediationPlacementId; // The placement ID from the mediation that showed the ad
string countryCode = adInfo.Country; // "US" for the United States, etc - Note: Do not confuse this with currency code which is "USD"
string networkName = adInfo.NetworkName; // Display name of the network that showed the ad (e.g. "AdColony")
string adUnitIdentifier = adInfo.AdUnitIdentifier; // The MAX Ad Unit ID - This only indicates that the current ad was loaded using this ad placement, and does not represent the ad placement of the mediation
string placement = adInfo.Placement; // The placement this ad's postbacks are tied to
string networkPlacement = adInfo.NetworkPlacement; // The placement ID from the network that showed the ad
}
You can also retrieve a precision evaluation for the revenue value, as shown in the following example:
string revenuePrecision = adInfo.RevenuePrecision;
This precision is one of the following values:
publisher_defined
— revenue is the price assigned by the publisher
exact
— revenue is the resulting price of a real-time auction
estimated
— the revenue amount is based on Auto CPM or FB Bidding estimates
undefined
— no revenue amount is defined and there is not enough data to estimate
an empty string, if revenue and precision are not valid (for example, in test mode)