0

The problem is that Apple rejects my app because when the button is clicked to purchase the "no ads" upgrade, it doesn't make the banner disappear until you close the app and re-open it. This is because I initialize all my RevMob code in the viewController.swift file. I have a boolean in place that turns to false as soon as the upgrade is purchase inside this viewController.swift file. So next time you open the app and the viewController loads, the boolean is set to false and it doesn't allow the ads to appear.

Anybody know if this is the wrong way to go about this? Or is there an easy way to make them disappear immediately upon press of the no Ads button without having to close the app and re-open it?

//BANNER AD =======================================
let bannerBlock: () -> Void = {
    //Custom method defined below
    if UserDefaults.standard.object(forKey: "adsBool") as! Bool == true
    {
        self.showBannerWithCustomFrame()
    }
        else
    {
        //don't show ads because user purchased
    }
}
let bannerFailBlock: ((Error?) -> Void) = {error in
    NSLog("[RevMob Sample App] Session failed to start with error: \(error!.localizedDescription)")
}
RevMobAds.startSession(withAppID: "00000000000000000000",
    withSuccessHandler: bannerBlock,
    andFailHandler: bannerFailBlock)

This is how my bannerView is set up in my GameViewController

class GameViewController: UIViewController, RevMobAdsDelegate {
    var bannerView:RevMobBannerView?

    override func viewDidLoad() {
    super.viewDidLoad()

3 Answers3

1

From RevMob's banner documentation, there's a method called hideAd. Calling that method on the IAP callback would solve your problem right?

To hide the banner: banner!.hideAd()

Thiago Murakami
  • 965
  • 7
  • 11
  • I tried that but since I define it all in my viewController it doesn't work. I may have to work with the variable to make it global. I've tried it before but it kinda screws some things up. May be a way around it though. – Stevie Thiel Feb 13 '17 at 23:50
1

Let me see if i got your problem correctly, you want to hide your banner as soon as the purchase is made.

First, you need to set the bannerView as a property of your viewController.

Then you have to add this code inside the callback from the purchase success:
viewController.bannerView.removeFromSuperview();

Wilson Dong
  • 165
  • 8
0

I fixed it! Thanks for your help. I had to move the code from the GameViewController to the GameScene for the bannerAd so that I could remove it as soon as the purchase was made. Works perfectly.