4

I have an app that shows an interstitial ad after a few pages on a UIPageViewController. Usually the ad is OK, and I can dismiss it by its own 'X' button. But there are some ads (especially the ones about games like Clash of Kings, i've noticed) that will not dismiss some times regardless of how many times I hit the 'X' button.

I even have a time that dismisses modals such as the interstitial after 5 seconds, but with these particular ads, it won't work.

Here is my code:

func createAndLoadInterstitial() -> GADInterstitial {
    let interst = GADInterstitial(adUnitID: "..")
    interst.delegate = self
    let request = GADRequest()
    interst.load(request)

    return interst
}

func showInterstitial() {
    if interstitial.isReady {

            self.interstitial.present(fromRootViewController: self)
            self.timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(self.dismissInterstitial), userInfo: nil, repeats: false)

    } else {
        print("Ad wasn't ready")
    }
}

func dismissInterstitial() {

    self.dismiss(animated: true, completion: nil) //THIS WORKS FINE EXCEPT FOR THESE PARTICULAR ADS.

}

I tried making sure it was on the main thread as well with DispatchQueue.main.async but again, this doesn't work every time.

Is there a way to fix this, or something I might be missing?

Thanks.

Jacobo Koenig
  • 11,728
  • 9
  • 40
  • 75

1 Answers1

0

Haven't used ads before but saw this behavior in games. Things that come to my mind:

  1. Does it have a delegate method which is called and then you dismiss the ad?
  2. If there is no delegate method then might be that the ad is 'cheating' and shows the 'x' button with no purpose.

Possible solution: How about creating a transparent view and create a gesture recognizer and close when it's tapped?

Tung Fam
  • 7,899
  • 4
  • 56
  • 63
  • The transparent view will then prevent the users from actually clicking the ad and visiting the advertiser, hurting you, the developer, not getting ad clicks, and maybe being against the TOS and guidelines of AdMob, since you are preventing users from using the ad as intended. And since the "X" button is different on every interstitial, I'm not sure how we can implement this without going against google's practices. Maybe a UIButton at the top left corner? But is that also against the TOS? Who knows. The AdMob SDK is broken when it come to closing interstitials and needs to be fixed internally – Lucas P. Oct 14 '19 at 08:37