AdMob Refresh Requests
Answer to my 1st, 2nd, and 3rd question:
1st this is my setup, I have the bannerView inside a headerView which seems to be totally fine. I'm also using a TabBarController
. Btw the vc the collectionView is in handles the bannerView
and load(GADRequest())
. The headerView only displays the ad so I don't have to worry about it constantly getting called as the user scrolls and the headerView is recycled. You can read the link in my set up for more details.
2nd AdMob's BannerView has a delegate method that gets called when a new ad is received:
MyController: GADBannerViewDelegate {
/// Tells the delegate an ad request loaded an ad.
func adViewDidReceiveAd(_ bannerView: GADBannerView) {
print("adViewDidReceiveAd")
}
}
3rd. I placed a break point on that print statement to see what happens and here are the results.
When I left the headerView visible (didn't scroll it off of the scene) the delegate method fired every 60 secs. I could be off by a few seconds because I looked at the time on my computer and didn't use a timer. Anyway pretty much every 60 secs the break point was hit and the test ad was changed.
As soon as I scrolled the headerView off of the scene and waited the breakpoint never got hit which means that the delegate method was never called. I waited 10 minutes and nothing happened -no ads were served.
As soon as I scrolled the headerView back on scene, I waited a several seconds and the breakpoint was eventually hit which means the delegate was called. Like in the first scenario it got hit every 60 seconds after that.
I switched to a different tab, left for a few minutes and the same exact thing in #2 happened, break point wasn't hit because the delegate wasn't called.
As soon as I came back to the tab with the headerView, the same thing in #3 happened, breakpoint was hit every 60secs because the delegate was called.
I went to the background and like #2 again the break point wasn't hit because the delegate wasn't called.
As soon as I came back from the background like #3 the breakpoint was hit every 60secs because the delegate was called.
My conclusion is that the bannerView DEFINITELY knows when it's not present on the scene. Wether a tab is changed, the app goes to the background (probably uses a notification), and most mysteriously it even knows when it's a subView of another view and that view is scrolled on/off the scene.
I'm in the Bronx, NY, it's 8am (I started testing around 7am) and the ad changed basically every 60 seconds. Maybe in other parts of the world, different times of the day, or different times of the year the duration might be longer or shorter?
Knowing what I know now I think that it's best that I let Google monitor the load(GADRequest())
and change the ads when it's ready. An ad changing every 60s is fine by me. If the scene can hold the user's attention for longer than a minute that's 2 ads served. It's more beneficial because I can spend more time trying to keep their attention than focus on serving them an ad.
As far as the code from my question to handle all the off cases it seems the bannerView is capable of handling all of that on it's own. It's less code for me to maintain and deal with and more importantly it's 1 less reason to worry about getting banned for handling something improperly.
In summary (this works best for me)
let Google handle/monitor the
bannerView.load(GADRequest())
to serve news adsdon't customize the refresh, it seems to change every 60 secs on it's own
when using a bannerView (and possibly letting Google monitor the
load(GADRequest()))
ads aren't requested when the screen is off so no need to waste time worrying about it
Answer to my 4th question:
The Monetization page to open App Refresh doesn't seem to exist anymore. After you login into AdMob follow these 5 steps (a new screen will appear for steps 3, 4, and 5 after your click your blue ad unit name in step 2).