(EN) iOS_Swift Interstitial - adxcorp/ADXLibrary_Integration GitHub Wiki

Interstitial Integration

MyViewController.swift

class ViewController: UIViewController {
    fileprivate var mopubInterstitial : MPInterstitialAdController!

    override func viewDidLoad() {
        super.viewDidLoad()
        loadInterstitial()
    }
}


extension ViewController : MPInterstitialAdControllerDelegate {
    func loadInterstitial() {
        mopubInterstitial = MPInterstitialAdController(forAdUnitId: "<YOUR_ADUNIT_ID_HERE>")
        mopubInterstitial.delegate = self
        mopubInterstitial.loadAd()
    }
        
    func showInterstitial() {
        if(mopubInterstitial.ready) {
            mopubInterstitial.show(from: self);
        }
    }
        
    func interstitialDidLoadAd(_ interstitial: MPInterstitialAdController!) {
       
    }
}

Receiving optional delegate callbacks

MPInterstitialAdControllerDelegate provides various callbacks, such as when ad has been successfully loaded and when it is presented or dismissed. Please refer to callback methods found by looking at MPInterstitialAdControllerDelegate protocol in MPInterstitialAdController.h and use them appropriately to your needs.