Jack.Right Jack.Right - 5 months ago 47
iOS Question

GADInterstitial AdMob showing default ad every time

In my app I am using a

GADInterstitial
and its showing the ad perfectly but its showing the same default ad of AdMob every time.
Here is my code:

self.interstitialAd = GADInterstitial(adUnitID: "ca-app-pub-xxxxxxxxxx/xxxxxxxxxx")
let request = GADRequest()
self.interstitialAd.loadRequest(request)
self.interstitialAd = reloadInterstitialAd()

func reloadInterstitialAd() -> GADInterstitial {
var interstitial = GADInterstitial(adUnitID: "ca-app-pub-xxxxxxxxxx/xxxxxxxxxx")
interstitial.delegate = self
interstitial.loadRequest(GADRequest())
return interstitial
}


And the resulting ad:

enter image description here

Answer

The default ad you're referring to is the test ad AdMob delivers when you're presenting ads on a test device. If your Ad Unit ID is correct, real paid ads will appear in the release version of your application.

Also, your code is redundant. The first 3 lines aren't necessary as you're doing the same thing in your reloadInterstitialAd() function. Remove them. For example:

override func viewDidLoad() {
    self.interstitialAd = loadInterstitialAd()
}

func loadInterstitialAd() -> GADInterstitial {
    let interstitial = GADInterstitial(adUnitID: "ca-app-pub-xxxxxxxxxx/xxxxxxxxxx")
    interstitial.delegate = self
    interstitial.loadRequest(GADRequest())
    return interstitial
}

I've also renamed the function to loadInterstitialAd() to make it clearer.

Comments