iOS SDK - Ad optimization
Best loaded ad
bestLoadedAd returns the ad the next show(on:) would display, or nil if there is none. Set bestLoadedAdListener to be notified when it changes:
let interstitial = A11.shared.getInterstitialAd(adUnitID: "adUnitID")
interstitial.bestLoadedAdListener = self
let current: AdInfo? = interstitial.bestLoadedAd
extension GameViewController: BestLoadedAdListener {
func onBestLoadedAdChanged(adInfo: AdInfo?) {
// adInfo is nil when no ad is ready
}
}
Caution
bestLoadedAdListener is a weak reference. Keep a strong reference to your listener for as long as you want updates.
External loss reporting
If an impression for an ad unit goes to an ad source outside the MDN11 SDK, call notifyLossToExternal, so the MDN11 SDK can factor it into its decisions.
let interstitial = A11.shared.getInterstitialAd(adUnitID: "adUnitID")
interstitial.notifyLossToExternal(price: Decimal(2.50)) // eCPM the external source served at
// Or when the price isn't known:
interstitial.notifyLossToExternal()
Caution
price must be the eCPM (effective cost per mille) the external source served at.
Info
Reports made before the ad unit's first load(on:) are kept (up to 8, oldest dropped) and applied when it loads.