🖥️Banner Ad

To receive Banner Ads, you need to conform to the MediationAdDelegate protocol. This protocol will notify you when the ad is successfully loaded or failed to load.

Implementation:

extension MainViewController: MediationAdDelegate {
    func onAdFailedToLoad(error: AdError) {
        print("Banner Ad request failed with reason \(error.description)")
    }

    func onBannerAdLoaded(bannerAd: MediationBannerAd) {
        guard let bannerview = bannerAd.view else {
            print("Banner Ad request failed with reason banner ad null")
            return
        }
        addBannerViewToView(bannerview)
        bannerAd.eventDelegate = self
    }
}

Tracking Events:

To track click and impression events for Banner Ads, conform to MediationBannerAdEventDelegate:

extension MainViewController: MediationBannerAdEventDelegate {
    func recordClick() {
        // Ad click recorded
    }
    
    func recordImpression() {
        // Ad impression recorded
    }
}

Last updated