diff --git a/ios/CCC/UI/Components/AdaptiveBannerAdView.swift b/ios/CCC/UI/Components/AdaptiveBannerAdView.swift index 3f78f292c8..b212a8f83e 100644 --- a/ios/CCC/UI/Components/AdaptiveBannerAdView.swift +++ b/ios/CCC/UI/Components/AdaptiveBannerAdView.swift @@ -9,6 +9,7 @@ import GoogleMobileAds import SwiftUI import UIKit +import Provider struct AdaptiveBannerAdView: UIViewControllerRepresentable { private var unitID: String @@ -29,6 +30,9 @@ struct AdaptiveBannerAdView: UIViewControllerRepresentable { bannerView.adUnitID = unitID bannerView.rootViewController = viewController + // Set the delegate to the context coordinator + bannerView.delegate = context.coordinator + viewController.view.addSubview(bannerView) viewController.view.frame = CGRect(origin: .zero, size: adSize.size) @@ -50,4 +54,18 @@ struct AdaptiveBannerAdView: UIViewControllerRepresentable { ) { // no impl } + + // SDK uses + func makeCoordinator() -> AdaptiveBannerAdCoordinator { + return AdaptiveBannerAdCoordinator() + } + + class AdaptiveBannerAdCoordinator: NSObject, GADBannerViewDelegate { + func bannerView(_ bannerView: GADBannerView, didFailToReceiveAdWithError error: Error) { + let throwable = KotlinThrowable( + message: "InterstitialAd show \(error.localizedDescription)" + ) + logger.e(throwable: throwable, tag: logger.tag, message: { String(describing: throwable.message) }) + } + } }