Zac Zac - 1 year ago 239
Swift Question

Programmatically add AdMob banner

Is there a way to implement adMob banners programmatically so that I can remove them with an in-app purchase?

Something like the iAd:

self.canDisplayBannerAds = true

When there is that line of code the ads are displayed, else the space is used for other views, like a uitableview.

Answer Source

The following is what I used for my in-app purchasing (IAP), and it works like a charm. It's executed once the IAP is bought.

func removeAds(){
    let theValue = 10
    NSUserDefaults.standardUserDefaults().setObject(theValue, forKey: "val")

Just create IBOutlets for your ads.