我添加到我的游戏Google AdMob中,我创建了一个新课程来展示我的广告并且无法正常使用。
我的横幅视图类
import Foundation
import GoogleMobileAds
class MyBannerView: GADBannerView, GADBannerViewDelegate {
let bannerView: GADBannerView = GADBannerView.init(adSize: kGADAdSizeSmartBannerPortrait)
func adViewDidReceiveAd(bannerView: GADBannerView!) {
bannerView.hidden = false
}
func adView(bannerView: GADBannerView!,
didFailToReceiveAdWithError error: GADRequestError!) {
print("adView:didFailToReceiveAdWithError: \(error.localizedDescription)")
}
}
我用这个here创建了这个类。
游戏场景
import GoogleMobileAds
class GameViewController: UIViewController , GADBannerViewDelegate {
var bannerView: GADBannerView = GADBannerView.init(adSize: kGADAdSizeSmartBannerPortrait)
override func viewDidLoad() {
super.viewDidLoad()
self.bannerView.delegate = self
bannerView.adUnitID = "ca-app-pub-8242170233085386/3052401353"
}
}
答案 0 :(得分:3)