let adView = GADBannerView(adSize: kGADAdSizeBanner) adView.adUnitID = "YOUR_AD_UNIT_ID" adView.rootViewController = self adView.delegate = self self.view.addSubview(adView)
let request = GADRequest() adView.load(request)
func adViewDidReceiveAd(_ bannerView: GADBannerView) { print("Ad loaded successfully") }
func adView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: GADRequestError) { print("Ad failed to load: (error.localizedDescription)") }