user7124426 user7124426 - 7 months ago 141
iOS Question

admob interstitial ad is never ready

i have this game and i created 3 funcions in my gameviewcontroller and here they are

func getInterstitialAd(){
interstitial = GADInterstitial(adUnitID: "ca-app-pub-1782852253088296/5018877964")
let requestInterstitial = GADRequest()

func showAd() {

if (interstitial.isReady == true){
interstitial.present(fromRootViewController: GameViewController())
print("ad wasn't ready")
interstitial = createAd()


func createAd() -> GADInterstitial{
let interstital = GADInterstitial(adUnitID: "ca-app-pub-1782852253088296/5018877964")
return interstital

and in one of my scene called StartMenu , i call those function

var viewController: GameViewController!

and then i call the functions


but it always returns ad not ready , and false for interstitial.isReady,
but also the getInterstitial function is always called .

can someone help with that please


The problem is that it takes time to fetch interstitial ads. Your showAd() is called before ad has been cached. When you implement the GADInterstitialDelegate delegate, there is a function interstitialDidReceiveAd(ad: GADInterstitial!). That is the function that is triggered when ad is ready. That is when interstitial.isReady will return true. Hope this helps :-)