I have several questions that I'm confused with:
Who is best responsible for ad refreshing? After I load the request
bannerView.load(GADRequest())
is it best practice to let the developer or Google monitor it?Should the refresh times be as little as 30 seconds or a minimum of 60 seconds? It seems odd that they recommend 60 seconds but give you the option to choose 30 seconds. I've read on different threads that you can get penalized for all sorts of things and your AdMob account will get closed no questions asked. If that's the case if you pick 30 seconds inside the console and they recommend 60, if they feel anything is "funny" they can terminate your account based on that alone. It's a very oblique process.
It says If your app is automatically refreshing ads, make sure ad requests are not made when the screen is off. If the answer to my first question is to let Google monitor/automatically refresh (without using my code below) how would Google know whether the screen is off or not? For example, the ad is shown in
viewControllerA
but the user presses a button andviewControllerB
is pushed on. SinceviewControllerA
is still on the stack the ad will constantly get refreshed, I don't see how Google would know the screen is off untilviewControllerA
is deallocated. Also, if the user went to the background how would Google know? I'm assuming off means the user can no longer see the screen which means they can't see the ad so there's no need to refresh because they either switched tabs, pushed on another VC, or went to the background (all cases handled in the below code)Where is the link to the refresh console page? Before you could go to https://apps.admob.com > Monetize and you would end up on the page with the refresh options. When I log in I no longer see a Monetize option but get a sidebar with a bunch of icons. None of the icons bring me to the refresh page. FYI I just started using AdMob yesterday and I only saw the refresh page in videos and online tutorials so I never used it before.
It says here (emphasis mine):
Refreshing ads
We recommend that you have ads persist for 60 seconds or longer, depending on the functionality of your app. Our internal tests have shown that this ensures users have enough time to engage with ads, providing the best performance for both advertisers and publishers. Furthermore, these tests have shown that refreshing ads more often can hurt fill rate for our publishers.
If your app is automatically refreshing ads, make sure ad requests are not made when the screen is off. Also, if users navigate to and from pages with ads in an app over a short period of time, a new ad request should not be made sooner than the recommended 60 second rate.
But it also says here:
Banner ads
We recommend using the Google-optimized automatic refresh rate. The optimized rate is calculated using AdMob historical data to ensure the ads shown in your ad units are being refreshed at the best rate for banner ads.
You may also set a custom refresh rate of 30-120 seconds or disable refresh rate completely.
Here's how I would manage the requests myself every 30 secs taking into account when the user goes to the background, switches tabs, or pushes on another VC. If I don't do all of this and left it up to them ("We recommend using the Google-optimized automatic refresh rate"), how would Google know the screen is off or not?
var timer: Timer?
override viewDidLoad() {
super.viewDidLoad()
// instantiate bannerView ...
NotificationCenter.default.addObserver(self, selector: #selector(startAdRefreshTimer), name: UIApplication.willEnterForegroundNotification, object: nil)
// *** the screen is OFF
NotificationCenter.default.addObserver(self, selector: #selector(stopAdRefreshTimer), name: UIApplication.willResignActiveNotification, object: nil)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
startAdRefreshTimer()
}
// *** the screen is OFF
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
stopAdRefreshTimer()
}
@objc func startAdRefreshTimer() {
timer?.invalidate()
timer = Timer.scheduledTimer(withTimeInterval: 30,
repeats: true,
block: { [weak self](timer) in
self?.refreshAd()
})
}
func refreshAd() {
bannerView.load(GADRequest())
}
@objc func stopAdRefreshTimer() {
if timer != nil {
timer?.invalidate()
timer = nil
}
}
// this really isn't necessary because of what's in viewWillDisappear but I added it anyway
@objc func buttonToPushNextVCTapped() {
let nextVC = NextVC()
navigationController?.pushViewController(viewController: nextVC, animated: true, completion: { [weak self] in
// *** the screen is OFF
self?.stopAdRefreshTimer()
})
}
This isn't the perfect solution because if the user switched tabs back and forth quickly and repeatedly the requests would happen much sooner then 30 seconds which would probably get your account banned. This is just for example purposes.