简体   繁体   中英

Admob Ads not displaying iOS

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()
    }


}

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM