我正在使用Swift2和Xcode7开发iOS应用程序.我正在尝试实施AdMob,但它不会显示我的插页式广告.
override func viewDidLoad() {
super.viewDidLoad()
_interstitial = createAndLoadInterstitial()
}
func createAndLoadInterstitial()->GADInterstitial {
let interstitial = GADInterstitial(adUnitID: "interstitial_ID")
let gadRequest:GADRequest = GADRequest()
gadRequest.testDevices = ["test device id"]
interstitial.delegate = self
interstitial?.loadRequest(gadRequest)
return interstitial!
}
func interstitialDidReceiveAd(ad: GADInterstitial!) {
_interstitial?.presentFromRootViewController(self)
}
func interstitial(ad: GADInterstitial!, didFailToReceiveAdWithError error: GADRequestError!) {
print(error.localizedDescription)
}
func interstitialDidDismissScreen(ad: GADInterstitial!) {
_interstitial = createAndLoadInterstitial()
}
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
请求错误:无广告显示.
Wil*_*iam 10
Request Error: No ad to show.
表示您的请求已成功,但此时Admob无法为您的设备展示广告.确保始终展示广告的最佳方法是使用中介,以便将未实现的请求传递到其他广告网络.Admob提供了良好的机制来实现这一目标.