如何在后退按钮点击一次显示AdMob非页内广告

时间:2016-08-13 10:59:30

标签: ios swift admob

我有这段代码:

func createAndLoadInterstitial()  {
    interstitial = GADInterstitial(adUnitID: "ca-app-pub-xxxxxxxxxx/xxxxx")
    interstitial.delegate = self
    let request = GADRequest()
    interstitial.loadRequest(request)
}

override func viewDidAppear(animated: Bool) {
    if (interstitial.isReady && showAd) {
        showAd = false
        // print("iterstitialMain is ready")
        interstitial.presentFromRootViewController(self)
        self.createAndLoadInterstitial()
    }
    else {
        showAd = true
    }
}

它有效。但每当用户点击后退按钮时,它就会显示一则广告。

我想在用户点按后退按钮时只显示一次广告。相反,在一段时间后展示广告会更好吗?例如,每隔5分钟?

0 个答案:

没有答案