8
votes

I have a banner ad and an interstitial ad. They are appearing when I use the adUnitID's for testing purposes that AdMob gives you, but neither of them are showing when I use live ads. The banner just doesn't appear at all. When the interstitial ad appears, it is just completely black. The adUnitID's are correct. The ads on my other apps are currently appearing just fine. The problem occurs both when I use the iOS simulator and my device. Any ideas?

var interstitial: GADInterstitial!

func createAndLoadAd() -> GADInterstitial{
    let ad = GADInterstitial(adUnitID: "ca-app-pub-7863284438864645/1835730011")
    let request = GADRequest()
    ad.loadRequest(request)
    return ad

}


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
    authenticateLocalPlayer()
    self.bannerView.adUnitID = "ca-app-pub-7863284438864645/9358996816"
    self.bannerView.rootViewController  = self
    let request: GADRequest = GADRequest()
    self.bannerView.loadRequest(request)
    self.interstitial = self.createAndLoadAd()

}

override func viewDidAppear(animated: Bool) {
    _ = GADRequest()
    //request.testDevices = ["2077ef9a63d2b398840261c8221a0c9b"]
    showAd()

}
func showAd(){

    if(self.interstitial.isReady){
        print("ad ready")
        self.interstitial.presentFromRootViewController(self)

    }
    else{
        print("ad not ready")
        self.interstitial = createAndLoadAd()
    }


}
3
You should post your codeAdrian
It usually takes a few hours for the live ads to get active, last time I did it it took around 12 hours. :)Ivan Le Hjelmeland
That is actually what happened. If you post your comment as an answer I can mark it as the answer if you'd like. Thanks!LuKenneth

3 Answers

13
votes

This is an aside, because my problem looked similar, but was not.

App ID is NOT the same as Ad Unit ID.

And, stupidly, they BOTH start with ca-app-pub- and a lot of numbers. I was using the App ID which I can guarantee 100% does NOT work.

Yes, I feel pretty silly, but the folks at Google should have made them dissimilar.

5
votes

replace adUnitID with your own ad unit id in your Admob account. make sure you setup payment method, otherwise the ads wont show up

0
votes

They have both IDs that contains "~" telda and "/" slash