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에는 광고가 성공적으로 로드 되었을 때나 present 되거나 dismiss 될 때 등, 여러가지 이벤트 callback이 존재합니다. MPInterstitialAdController.h의 MPInterstitialAdControllerDelegate protocol을 확인해보시면 이러한 callback method의 리스트를 확인하실 수 있습니다. 필요에 따라 사용해주세요.