I use GADBannerView in another class that named Tools. But adViewDidReceiveAd delegate method doesn't fire in Tools class. What can I do?
class Tools: NSObject, GADBannerViewDelegate {
var viewController: UIViewController!
func showAds(viewController: UIViewController) -> Void {
self.viewController = viewController
let request: GADRequest = GADRequest()
request.testDevices = [kGADSimulatorID]
let bannerView = GADBannerView(adSize: kGADAdSizeSmartBannerPortrait)
bannerView.delegate = self
bannerView.rootViewController = viewController
bannerView.adUnitID = "ca-app-pub-xxx-xxx"
bannerView.loadRequest(request)
}
func adViewDidReceiveAd(bannerView: GADBannerView!) {
print("adViewDidReceiveAd");
viewController.view.addSubview(bannerView)
}
}
And, I called Tools in ViewController
override func viewDidLoad() {
super.viewDidLoad()
Tools().showAds(self);
}