• Updated

Loading an MREC

To load an MREC, call CreateMRec(), passing in your ad unit ID and desired adview position:

string mrecAdUnitId = "ios_ad_unit_ID"; // Retrieve the ID from your account
string mrecAdUnitId = "android_ad_unit_ID"; // Retrieve the ID from your account
#endif public void InitializeMRecAds() { // MRECs are sized to 300x250 on phones and tablets MaxSdk.CreateMRec(mrecAdUnitId, MaxSdkBase.AdViewPosition.Centered); MaxSdkCallbacks.MRec.OnAdLoadedEvent += OnMRecAdLoadedEvent; MaxSdkCallbacks.MRec.OnAdLoadFailedEvent += OnMRecAdLoadFailedEvent; MaxSdkCallbacks.MRec.OnAdClickedEvent += OnMRecAdClickedEvent; MaxSdkCallbacks.MRec.OnAdRevenuePaidEvent += OnMRecAdRevenuePaidEvent; MaxSdkCallbacks.MRec.OnAdExpandedEvent += OnMRecAdExpandedEvent; MaxSdkCallbacks.MRec.OnAdCollapsedEvent += OnMRecAdCollapsedEvent; } public void OnMRecAdLoadedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {} public void OnMRecAdLoadFailedEvent(string adUnitId, MaxSdkBase.ErrorInfo error) {} public void OnMRecAdClickedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {} public void OnMRecAdRevenuePaidEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {} public void OnMRecAdExpandedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {} public void OnMRecAdCollapsedEvent(string adUnitId, MaxSdkBase.AdInfo adInfo) {}

The above example creates an MREC centered on the display (Centered). The complete list of position options are:

  • TopLeft
  • TopCenter
  • TopRight
  • Centered
  • CenterLeft
  • CenterRight
  • BottomLeft
  • BottomCenter
  • BottomRight

Hiding and Showing an MREC

To show an MREC ad, call ShowMRec():


To hide an MREC ad, call HideMRec():


Stopping and Starting Auto-Refresh

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:


Start auto-refresh for an MREC ad with the following code:


Manually refresh the contents with the following code. Note that you must stop auto-refresh before you call LoadMRec().