4

I'm near completion with an app and I'm starting to add ad's to it. For adMob I have the following code in my viewdidLoad method:

    bannerAd.adUnitID = "...."
    bannerAd.rootViewController = self
    bannerAd.load(GADRequest())

This is currently only on the first view controller that pops up. The ad is on the bottom of a landscape only app. My question is is okay to add this to all of my view Controllers that you can segue too?

I'm not exactly sure if I need to close out the ad when I leave view controllers, or if this is handled automatically. It would be simple for me to add this to all view controllers, but I'm not sure if this creates more ad requests as the user switches from view to view, or how it works...

I'm new to app development and am getting ready to roll out my first app. I would appreciate any help and I thank you in advance!!!!

Daniel Storm
  • 18,301
  • 9
  • 84
  • 152
Discoveringmypath
  • 1,049
  • 9
  • 23
  • 1
    Create one `GADBannerView` to use across the entire application: http://stackoverflow.com/a/33697848/2108547 – Daniel Storm Feb 28 '17 at 18:43
  • Is there a benefit to having one as opposed to each view controller having their own? – Discoveringmypath Feb 28 '17 at 20:31
  • This way you only need to init the `GADBannerView` once instead of init'ing it each time a new View Controller is presented. Will also stop you from rewriting the same code in each View Controller. – Daniel Storm Feb 28 '17 at 20:39
  • I added the GADBannerViewDelegate to see when the adViewDidRecieveAd fires. I noticed that when I place a View in each view controller that this adViewDidRecieveAd fires each time you generate a new view controller on the stack. Is that kind of thing going to get my account suspended though? because more ads are generated as the player moves through each view controller? I just want to be sure I'm doing this right. I attempted to make a global GADBannerView, but something went wrong, I'll have to play around with it to get it to work... – Discoveringmypath Feb 28 '17 at 20:54

0 Answers0