MREC Ads

Programmatic Method

The following code shows you how to load an MREC by using your ad unit ID and desired position (MAX sizes the MREC automatically):

final String _mrec_ad_unit_ID = Platform.isAndroid ? "android_mrec_ad_unit_ID" : "ios_mrec_ad_unit_ID";

public void initializeMRecAds()
{
  // MAX sizes MRECs to 300×250 on phones and tablets
  AppLovinMAX.createMRec(_mrec_ad_unit_ID, AdViewPosition.bottomCenter);
}

Widget Method

You can also render a MREC directly in your widget tree:

final String _ad_unit_ID = Platform.isAndroid ? "android_ad_unit_ID" : "ios_ad_unit_ID";
MaxAdView(
  adUnitId: _ad_unit_ID,
  adFormat: AdFormat.mrec,
  listener: AdViewAdListener(onAdLoadedCallback: (ad) {
    ⋮
  }, onAdLoadFailedCallback: (adUnitId, error) {
    ⋮
  }, onAdClickedCallback: (ad) {
    ⋮
  }, onAdExpandedCallback: (ad) {
    ⋮
  }, onAdCollapsedCallback: (ad) {
    ⋮
  })
)

Stopping and Starting Auto-Refresh

There may be cases when you would like to stop auto-refresh, for instance, when you hide an MREC ad or want to manually refresh. Stop auto-refresh for an MREC ad with the following code:

  • AppLovinMAX.showMRec(ad-unit-ID);
    AppLovinMAX.stopMRecAutoRefresh(ad-unit-ID);
  • MaxAdView(
        adUnitId: ad-unit-ID,
        adFormat: AdFormat.mrec,
        isAutoRefreshEnabled: false,
        ⋮

Start auto-refresh for a banner ad with the following code:

  • AppLovinMAX.startMRecAutoRefresh(ad-unit-ID);
  • MaxAdView(
        adUnitId: ad-unit-ID,
        adFormat: AdFormat.mrec,
        isAutoRefreshEnabled: true,
        ⋮