Skip to main content
Version: 3.3.1

MREC

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

You can use our demo app as a reference project.

Demo App

Check If Ad Is Loaded

// MREC view
mrec.isReady

Display

AppodealMRECView is a subclass of AppodealBannerView. The size of AppodealMRECView is 300x250.

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

import UIKit
import Appodeal

class YourViewController: UIViewController, AppodealBannerViewDelegate {

override func viewDidLoad () {
super.viewDidLoad()
// required: init ad banner
let mrecView: AppodealMRECView = AppodealMRECView()
mrecView.usesSmartSizing = false
mrecView.rootViewController = self

// optional: set delegate
mrecView.delegate = self

// required: add banner to superview and call -loadAd to start banner loading
self.view.addSubview(mrecView)
mrecView.loadAd()
}

// optional: implement any of AppodealBannerViewDelegate methods
func bannerViewDidLoadAd(_ bannerView: APDBannerView, isPrecache precache: Bool) {
NSLog("bannerView was loaded")
}

func bannerView(_ bannerView: APDBannerView, didFailToLoadAdWithError error: Error) {
NSLog("bannerView failed to load");
}

func bannerViewDidInteract(_ bannerView: APDBannerView) {
NSLog("bannerView was clicked")
}

func bannerViewDidShow(_ bannerView: APDBannerView) {
NSLog("bannerView was shown")
}

func bannerViewExpired(_ bannerView: APDBannerView) {
NSLog("bannerView did expire and could not be shown")
}
}

Manual Caching

MREC does not support autocache.

To cache MREC use:

// MREC view
mrec.loadAd()

Read more on manual caching in our FAQ.

Callbacks

Callbacks are used to track different events of an ad's lifecycle, e.g., when a MREC has been successfully loaded or is about to appear. To get them, you need to set the delegate as follows:

//set delegate
Appodeal.setBannerDelegate(self)

Usually, the class that implements banners is also the delegate class. That's why the delegate property can be set to self.

Now you can use the following callbacs methods:

// banner was loaded (precache flag shows if the loaded ad is precache)
func bannerDidLoadAdIsPrecache(_ precache: Bool) {}
// banner was shown
func bannerDidShow() {}
// banner failed to load
func bannerDidFailToLoadAd() {}
// banner was clicked
func bannerDidClick() {}
// banner did expire and could not be shown
func bannerDidExpired() {}

note

All callbacks are called on the main thread.

Placements

Appodeal SDK allows you to tag each impression with different placement. To be able to use placements, you need to create them in Appodeal Dashboard. Read more about placements.

Appodeal.showAd(.MREC, forPlacement: placement, rootViewController: self)

If the loaded ad can't be shown in a specific placement, nothing will be shown. If auto caching is enabled, the SDK will start to cache another ad, which can affect display rate. To save the loaded ad for future use (for instance, for another placement), check if the ad can be shown before calling show method:

Appodeal.canShow(.MREC, forPlacement: placement)

You can configure your impression logic for each placement.

If you have no placements or call Appodeal.show with a placement that does not exist, the impression will be tagged with 'default' placement with corresponding settings applied.

Important!

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

Get Predicted eCPM

This method returns the expected eCPM for the cached ad. The amount is calculated based on historical data for the current ad unit.

Appodeal.predictedEcpm(for: .MREC)

Check If Ad is Initialized

Appodeal.isInitialized(for: .MREC)

Returns true if MREC was initialized.

Check if Autocache Is Enabled For Ad

MREC does not support autocache.

Hide

MREC is a view. To hide MREC, remove it from superView

// MREC view
mrec.removeFromSuperview()