AdBannerView 未处理的错误 -- iAds 错误。添加在模拟器中正常运行,但给出一个奇怪的警告?
AdBannerView unhandled error -- Error with iAds. The add comes up fine in the simulator, but give a strange warning?
这是我收到的错误/警告:
2016-01-20 13:21:58.375 TEst[11131:3816829] [AppDeveloper] ADBannerView:未处理的错误(没有委托或委托未实现 didFailToReceiveAdWithError:):错误域=ADErrorDomain 代码=7 "Ad was unloaded from this banner" UserInfo ={ADInternalErrorCode=7, NSLocalizedFailureReason=广告已从此横幅中卸载,ADInternalErrorDomain=ADErrorDomain}
我的代码如下所示:
我错过了什么吗? (我附上了我的 iAd 横幅作为出口,并将其称为 adBanner)。
您需要添加类似
adBanner.delegate = 自己
并实现函数 didFailToReceiveAdWithError:
正如上面的用户所说,您需要致电
adBanner.delegate = self
在您的 ViewDidLoad 中并在您的场景中实现委托来处理不同的横幅状态。使用扩展来保持代码清洁可能是最简单的方法。
//Delegates AdMob Banner
extension GameScene: GADInterstitialDelegate {
func adViewDidReceiveAd(bannerView: GADBannerView!) {
print("AdMob banner did load, showing")
// animate banner into your view/scene
}
func adViewWillPresentScreen(bannerView: GADBannerView!) {
print("AdMob banner clicked")
// pause game if needed as ad was pressed
}
func adViewDidDismissScreen(bannerView: GADBannerView!) {
print("AdMob banner closed")
// banner closed
}
func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
print("AdMob banner error")
// handle error, hide from view etc
}
}
我专门为 spriteKit 制作了一个广告助手,你可能会发现它很有用
https://github.com/crashoverride777/Swift2-iAds-AdMob-CustomAds-Helper
这是我收到的错误/警告: 2016-01-20 13:21:58.375 TEst[11131:3816829] [AppDeveloper] ADBannerView:未处理的错误(没有委托或委托未实现 didFailToReceiveAdWithError:):错误域=ADErrorDomain 代码=7 "Ad was unloaded from this banner" UserInfo ={ADInternalErrorCode=7, NSLocalizedFailureReason=广告已从此横幅中卸载,ADInternalErrorDomain=ADErrorDomain}
我的代码如下所示:
我错过了什么吗? (我附上了我的 iAd 横幅作为出口,并将其称为 adBanner)。
您需要添加类似 adBanner.delegate = 自己 并实现函数 didFailToReceiveAdWithError:
正如上面的用户所说,您需要致电
adBanner.delegate = self
在您的 ViewDidLoad 中并在您的场景中实现委托来处理不同的横幅状态。使用扩展来保持代码清洁可能是最简单的方法。
//Delegates AdMob Banner
extension GameScene: GADInterstitialDelegate {
func adViewDidReceiveAd(bannerView: GADBannerView!) {
print("AdMob banner did load, showing")
// animate banner into your view/scene
}
func adViewWillPresentScreen(bannerView: GADBannerView!) {
print("AdMob banner clicked")
// pause game if needed as ad was pressed
}
func adViewDidDismissScreen(bannerView: GADBannerView!) {
print("AdMob banner closed")
// banner closed
}
func adView(bannerView: GADBannerView!, didFailToReceiveAdWithError error: GADRequestError!) {
print("AdMob banner error")
// handle error, hide from view etc
}
}
我专门为 spriteKit 制作了一个广告助手,你可能会发现它很有用 https://github.com/crashoverride777/Swift2-iAds-AdMob-CustomAds-Helper