I am trying to load an interstitial ad, I followed the tutorial and have since checked it a number of times to no avail. I am hoping someone here can see something that I cannot. I have gone through the debug console and I cannot find a solution there. The app isn't crashing, the ad just isn't loading when it is due to.
Below is the first part of my view controller, the ad is implemented in the view did load as bellow. Any help would be much appreciated.
I am calling it appropriately in the app delegate and my info p.list has the required items.
class TodaysMissionViewController: UIViewController, GADFullScreenContentDelegate {
@IBOutlet weak var MissionText: UITextView!
var missionText : String = ""
let remoteConfig = RemoteConfig.remoteConfig()
let settings = RemoteConfigSettings()
var interstitial : GADInterstitialAd?
override func viewDidLoad() {
super.viewDidLoad()
let request = GADRequest()
GADInterstitialAd.load(withAdUnitID: "ca-app-pub-3940256099942544/4411468910",
request: request,
completionHandler: { [self] ad, error in
if let error = error {
print("Failed to load interstitial ad with error: \(error.localizedDescription)")
return
}
interstitial = ad
interstitial?.fullScreenContentDelegate = self
})
configureFirebaseFetch()
MissionText.text = missionText
if interstitial != nil {
interstitial?.present(fromRootViewController: self)
} else {
print("Ad wasn't ready")
}
func ad(_ ad: GADFullScreenPresentingAd, didFailToPresentFullScreenContentWithError error: Error) {
print("Ad did fail to present full screen content.")
}
/// Tells the delegate that the ad will present full screen content.
func adDidPresentFullScreenContent(_ ad: GADFullScreenPresentingAd) {
print("Ad will present full screen content.")
}
/// Tells the delegate that the ad dismissed full screen content.
func adDidDismissFullScreenContent(_ ad: GADFullScreenPresentingAd) {
print("Ad did dismiss full screen content.")
}
}