How to implement iAd Preroll Videos in Swift and iOS 9

I'm trying to play a Preroll iAd Video into my game without having a video play afterward which is how I see it's done in all of the examples I've seen. When I go to play the Preroll iAd the AV View Controller is displayed but nothing plays and I get into my error case as shown below saying it couldn't play. What I'm going for is done in games like "Pop The Lock" when it gives you a second chance if you watch a video ad.



In my AppDelegate.swift I have the following code to prepare the iAd video.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool

{

// Override point for customization after application launch.

AVPlayerViewController.preparePrerollAds()

return true

}



Then in my ViewController I have the following to play the ad...



import AVFoundation

import iAd

//this is declared at the top

let adPlayerController = AVPlayerViewController()

//this gets called inside of a function

adPlayerController.playPrerollAdWithCompletionHandler({ (error) -> Void in

if error != nil

{

print(error)

print("Ad could not be loaded")

}

else

{

print("Ad loaded")

}

})

Are you saying the vended ad is blank?

How to implement iAd Preroll Videos in Swift and iOS 9
 
 
Q