MREC is 300x250 banner. This type can be useful if the application has a large free area for placing a banner in the interface.

1. Initialize MREC

1. Import the namespaces:

using AppodealStack.Monetization.Api;
using AppodealStack.Monetization.Common;
2.  Add the following code within the  Start() method of your main scene’s MonoBehavior:  
Appodeal.Initialize("YOUR_APPODEAL_APP_KEY", AppodealAdType.Mrec, this);
Initialization method requires 2 parameters:

  • appKey - appKey is generated when you add an application to Appodeal.

  • adType - Ad types can be combined using "|" operator. For example, AppodealAdType.Interstitial | AppodealAdType.Banner.

By default, auto caching is enabled: Appodeal SDK starts to load MREC right away after the initialization method is called. The next MREC ad starts to load after the previous one was shown.

2. Display MREC

MREC ads are refreshed every 15 seconds automatically by default. To display MREC, you need to call the following code in the activity:

Appodeal.ShowMrecView((int) yPosition, (int) xPosition, (string) placement);
For xPosition and yPosition use custom int value or constants:

  • AppodealViewPosition.HORIZONTAL_SMART — to use the full-screen width;
  • AppodealViewPosition.HORIZONTAL_CENTER — to center a banner horizontally;
  • AppodealViewPosition.HORIZONTAL_RIGHT — to align a banner to the right;
  • AppodealViewPosition.HORIZONTAL_LEFT — to align a banner to the left;

For yPosition you can use custom int value or constants:

  • AppodealViewPosition.VERTICAL_TOP — to align a banner to the top of the screen;
  • AppodealViewPosition.VERTICAL_BOTTOM — to align a banner to the bottom of the screen.

To set your custom width and height, you can use the constants of The Unity’s  Screen.width  and  Screen.height  with a constant value.

3. Hide MREC

Appodeal.HideMrecView();

4. MREC placements

Appodeal SDK allows you to tag each impression with different placement. For using 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 like this in your activity:

Appodeal.ShowMrecView((int) yPosition, (int) xPosition, (string) placement);

If the loaded ad can’t be shown for a specific placement, nothing will be shown. 

You can configure your impression logic for each placement.

If you have no placements, or call  Appodeal.Show  with placement that do not exist, the impression will be tagged with 'default' placement and its settings will be applied.

Important!

Placement settings affect ONLY ad presentation, not loading or caching.

5. MREC 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. To implement them, you need to follow three steps:

1. Extend your public class with IMrecAdListener:

YourClassName : IMrecAdListener;
2. Then call the following method:
Appodeal.SetMrecCallbacks(this);
3. Now you can use the following callback methods within your  public class :
#region Banner callback handlers

// Called when mrec is loaded precache flag shows if the loaded ad is precache)
public void OnMrecLoaded(bool precache) 
{ 
	print("mrec loaded"); 
} 

// Called when mrec failed to load
public void OnMrecFailedToLoad() 
{ 
	print("mrec failed"); 
} 

// Called when mrec is shown
public void OnMrecShown() 
{ 
	print("mrec opened"); 
}

// Called when mrec is failed to show
public void OnMrecShowFailed()
{
    print("mrec failed to show");   
}

// Called when mrec is clicked 
public void OnMrecClicked() 
{ 
	print("mrec clicked"); 
} 

// Called when mrec is expired and can not be shown
public void OnMrecExpired() 
{ 
	print("mrec expired");  
} 

#endregion


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 .

6. 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:

Appodeal.GetPredictedEcpm(AppodealAdType.Mrec);