Admob Ads not displaying iOS

旧时模样 提交于 2019-12-23 07:59:06

问题


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


}

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/34797974/admob-ads-not-displaying-ios

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!