Mrec
Mrec is a 300x250 banner. This type can be useful if the application has a large free area for placing a banner in the interface.
Displaying
Mrec ads are refreshed every 15 seconds automatically by default.
- UPM Distribution
- Manual Distribution
To display mrec, use the following method:
Appodeal.ShowMrecView(yPosition, xPosition, "placementName");
Use int value or one of the constants below for yPosition
:
AppodealViewPosition.VerticalTop
— to align a mrec to the top of the screen.AppodealViewPosition.VerticalBottom
— to align a mrec to the bottom of the screen.
Use int value or one of the constants below for xPosition
:
AppodealViewPosition.HorizontalSmart
— to use the full-screen width.AppodealViewPosition.HorizontalCenter
— to center a mrec horizontally.AppodealViewPosition.HorizontalRight
— to align a mrec to the right.AppodealViewPosition.HorizontalLeft
— to align a mrec to the left.
To display mrec, use the following method:
Appodeal.showMrecView(yPosition, xPosition, "placementName");
Use int value or one of the constants below for yPosition
:
Appodeal.BANNER_TOP
— to align a mrec to the top of the screen.Appodeal.BANNER_BOTTOM
— to align a mrec to the bottom of the screen.
Use int value or one of the constants below for xPosition
:
Appodeal.BANNER_HORIZONTAL_SMART
— to use the full-screen width.Appodeal.BANNER_HORIZONTAL_CENTER
— to center a mrec horizontally.Appodeal.BANNER_HORIZONTAL_RIGHT
— to align a mrec to the right.Appodeal.BANNER_HORIZONTAL_LEFT
— to align a mrec to the left.
Hide Mrec
To hide a mrec ad use the following method:
- UPM Distribution
- Manual Distribution
Appodeal.HideMrecView();
Appodeal.hideMrecView();
Callbacks
The callbacks are used to track different events in the lifecycle of an ad, e.g. when an ad was clicked on or closed. Follow the steps below to implement them:
- UPM Distribution
- Manual Distribution
Subscribe to the desired mrec event using one of the options from this guide. (you can subscribe to any number of events you want)
AppodealCallbacks.Mrec.OnLoaded += (sender, args) => { };
You will find all existing mrec events in the example below:
public void SomeMethod()
{
AppodealCallbacks.Mrec.OnLoaded += (sender, args) => OnMrecLoaded(args.IsPrecache);
AppodealCallbacks.Mrec.OnFailedToLoad += (sender, args) => OnMrecFailedToLoad();
AppodealCallbacks.Mrec.OnShown += (sender, args) => OnMrecShown();
AppodealCallbacks.Mrec.OnShowFailed += (sender, args) => OnMrecShowFailed();
AppodealCallbacks.Mrec.OnClicked += (sender, args) => OnMrecClicked();
AppodealCallbacks.Mrec.OnExpired += (sender, args) => OnMrecExpired();
}
#region MrecAd Callbacks
// Called when mrec is loaded precache flag shows if the loaded ad is precache)
private void OnMrecLoaded(bool isPrecache)
{
Debug.Log("Mrec loaded");
}
// Called when mrec failed to load
private void OnMrecFailedToLoad()
{
Debug.Log("Mrec failed to load");
}
// Called when mrec is failed to show
private void OnMrecShowFailed()
{
Debug.Log("Mrec show failed");
}
// Called when mrec is shown
private void OnMrecShown()
{
Debug.Log("Mrec shown");
}
// Called when mrec is clicked
private void OnMrecClicked()
{
Debug.Log("Mrec clicked");
}
// Called when mrec is expired and can not be shown
private void OnMrecExpired()
{
Debug.Log("Mrec expired");
}
#endregion
- Extend your class with
IMrecAdListener
interface:
class SomeClassName : IMrecAdListener {}
- Implement all required callback methods:
#region MrecAd callback handlers
// Called when mrec is loaded precache flag shows if the loaded ad is precache)
public void onMrecLoaded(bool precache)
{
Debug.Log("Mrec loaded");
}
// Called when mrec failed to load
public void onMrecFailedToLoad()
{
Debug.Log("Mrec failed to load");
}
// Called when mrec is shown
public void onMrecShown()
{
Debug.Log("Mrec shown");
}
// Called when mrec is failed to show
public void onMrecShowFailed()
{
Debug.Log("Mrec show failed");
}
// Called when mrec is clicked
public void onMrecClicked()
{
Debug.Log("Mrec clicked");
}
// Called when mrec is expired and can not be shown
public void onMrecExpired()
{
Debug.Log("Mrec expired");
}
#endregion
- Call the following method:
Appodeal.setMrecCallbacks(this);
All callbacks are called on native main threads that do not match the main thread of the Unity. If you need to receive callbacks in the main Unity thread follow our Callback Usage Guide.
Placements
Appodeal SDK allows you to tag each impression with different placement. To use placements, you need to create placements in Appodeal Dashboard. Read more about placements.
To show an ad with placement, you have to call show method with specifying placement's name:
- UPM Distribution
- Manual Distribution
Appodeal.ShowMrecView(yPosition, xPosition, "placementName");
Appodeal.showMrecView(yPosition, xPosition, "placementName");
Get Predicted eCPM
This method returns expected eCPM for a currently cached advertisement. The amount is calculated based on historical data for the current ad unit.
- UPM Distribution
- Manual Distribution
Appodeal.GetPredictedEcpm(AppodealAdType.Mrec);
Appodeal.getPredictedEcpm(Appodeal.MREC);