Search code examples
iosswiftsprite-kitiadads

Is there something wrong is my iAd code?


My app was approved just a couple of days ago and had an iAd banner on the bottom of the screen. I know that there it can take up to a week for ads to start appearing, but while I'm waiting.. can someone make sure that I don't have any errors in my code?

import UIKit
import SpriteKit
import iAd
import GameKit

class GameViewController: UIViewController, ADBannerViewDelegate, GKLocalPlayerListener {

var adBanner: ADBannerView!
override func viewDidLoad() {
    super.viewDidLoad()
    authenticateLocalPlayer()
    if let scene = GameScene(fileNamed:"GameScene") {
        // Configure the view.
        let skView = self.view as! SKView

        skView.ignoresSiblingOrder = true
        scene.scaleMode = .AspectFill

        skView.presentScene(scene)


    }

}

func loadBanner() {

    adBanner = ADBannerView(frame: CGRect.zero)
    adBanner.center = CGPoint(x: adBanner.center.x, y: view.bounds.size.height - adBanner.frame.size.height / 2)
    adBanner.delegate = self
    adBanner.hidden = true
    view.addSubview(adBanner)
}
func bannerViewDidLoadAd(banner: ADBannerView!) {
    adBanner.hidden = false
}
func bannerView(banner: ADBannerView!, didFailToReceiveAdWithError error: NSError!) {

    adBanner.hidden = true
}
func bannerViewActionShouldBegin(banner: ADBannerView!, willLeaveApplication willLeave: Bool) -> Bool {
    return true
}
override func shouldAutorotate() -> Bool {
    return true
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
        return .AllButUpsideDown
    } else {
        return .All
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Release any cached data, images, etc that aren't in use.
}

override func prefersStatusBarHidden() -> Bool {
    return true
}


func authenticateLocalPlayer() {
    let localPlayer = GKLocalPlayer.localPlayer()
    localPlayer.authenticateHandler = {(viewController, error) -> Void in

        if (viewController != nil) {
            self.presentViewController(viewController!, animated: true, completion: nil)
        }
        else {
            print((GKLocalPlayer.localPlayer().authenticated))
        }
    }
}

}

Right now it just displays a white rectangle. Is there anything wrong with my code, or do I just need to keep waiting for my app to start receiving ads?


Solution

  • iAd is officially discontinued as of tomorrow (June 30th, 2016). I am unsure of the "sign up" process now, but I believe Apple stopped registering apps to receive ads from their network some months ago