Search code examples
iosswiftadmob

How to stop showing AdMob banner ad correctly?


I am building an app which will display AdMob banner ad, and when user successfully purchased an IAP item, the banner ad will never show up again, and the screen area originally occupied by the banner ad will be used by the app real functions.

The question is how to dismiss the bannerView or does not init it on the next launch up? And how to insure AdMob Sdk will never refresh the ad content in the background?

I think we cannot just hide the bannerView with just a statement:

bannerView.isHidden = true

And, as we know, AdMob SDK use IDFA. But Apple will deny an app which use IDFA but not showing Ads.

Google has guides on how to show up ads, but I cannot find information about how to stop showing ads from Google.

How to get this problem out?


Solution

  • The question is how to dismiss the bannerView or does not init it on the next launch up? And how to insure AdMob Sdk will never refresh the ad content in the background?

    There are multiple ways to do this. One way I can think of is to add multiple targets in your Xcode project.

    And the easier way, the more practical way - at least for me, is to prevent the requests for ads through GADRequest().

    You can even do this even in AppDelegate, when setting Ids to your SDK.

    That's it. You may also set nil to the delegate property of your bannerView.

    And like what you've mentioned, just hide the bannerView's container, and everything should be perfect. I've worked on lots of applications with Admob, and I believe there should be no problem doing this approach.