我尝试将Admob interstitial集成到我的应用中,但我遇到了问题 - 广告仅在模拟器中显示。
我使用以下代码
class MenuViewController: UIViewController, GADInterstitialDelegate {
var interstitial: GADInterstitial?
override func viewDidLoad() {
loadInterstitial()
}
func loadInterstitial() {
var request = GADRequest()
request.testDevices = ["here is test device id"]
interstitial = GADInterstitial(adUnitID: "here is ID")
interstitial!.delegate = self
interstitial!.loadRequest(GADRequest())
}
override func viewDidAppear(animated: Bool) {
showAd()
}
func showAd() {
if !adsRemoved {
if self.interstitial!.isReady {
println("interstitial isReady")
self.interstitial!.presentFromRootViewController(self)
} else {
println("intersitial notReady")
}
}
self.interCount = 1
}
}
在设备上它始终在控制台中打印“intersitial notReady” 我用request.testDevices和没有使用request.testDevices来修改这两种情况。两者都没有在物理设备上工作,但在模拟器中显示。
我也有
func interstitialDidFailToReceiveAdWithError (
interstitial: GADInterstitial,
error: GADRequestError) {
println("interstitialDidFailToReceiveAdWithError: %@" + error.localizedDescription)
}
但它不起作用
问题出在哪里?