Search code examples
iosxcodeswiftiad

How to get iAds advertising in Swift


I have successfully implemented iAds. But they won't display an actual ad. What's wrong with this code?Any help would be greatly appreciated.

I have successfully implemented iAds. But they won't display an actual ad. What's wrong with this code?Any help would be greatly appreciated.

import iAd


class ViewController: UIViewController, MCBrowserViewControllerDelegate, ADBannerViewDelegate {

    @IBOutlet weak var adBannerView: ADBannerView!

override func viewDidLoad() {
        super.viewDidLoad()

        self.canDisplayBannerAds = true
        self.adBannerView?.delegate = self
        self.adBannerView?.hidden = true
}


    func bannerViewWillLoadAd(banner: ADBannerView!) {

    }

    func bannerViewDidLoadAd(banner: ADBannerView!) {
        self.adBannerView?.hidden = false
    }

    func bannerViewActionDidFinish(banner: ADBannerView!) {

    }

    func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {

        return true
    }

    func bannerView(banner: ADBannerView!, didFailtoRecieveAdWithError error: NSError!) {

    }
}

screenshot


Solution

  • Well your app won't show any ads until it is approved by Apple and Live in the App Store.