Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Admob Ads not displaying iOS

Tags:

ios

admob

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


}
like image 236
LuKenneth Avatar asked Jan 14 '16 19:01

LuKenneth


People also ask

Does AdMob work on iOS?

In future, if you already have an app on the App Store, you can let AdMob retrieve your app information. Set the app name to GoogleAdMobDemo and choose iOS for the platform option. Click Add to proceed to the next step. AdMob will then generate an App ID for the app.

How long does it take for AdMob to show ads?

How long does it take for ads to begin appearing after the first ad request? When apps are newly registered with AdMob, it typically takes up to an hour and a few ad requests to allow inventory to build. Because of this, you may not see live impressions immediately. Note: In some cases, it may take longer than an hour.

How do I show AdMob ads in app?

After you've set up an app in AdMob and added an ad unit to it, the last step is to implement the ad unit in your app's code. Follow the instructions in the Google Developers Get Started guide for Android or iOS. You'll need your app ID and ad unit ID during implementation.


2 Answers

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.

like image 58
Lloyd Sargent Avatar answered Sep 22 '22 23:09

Lloyd Sargent


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

like image 45
Jayce Avatar answered Sep 21 '22 23:09

Jayce