From 89eb729f1425fb416bd988066f42ef047f01352c Mon Sep 17 00:00:00 2001 From: Mustafa Ozhan Date: Sat, 30 Nov 2024 17:18:04 +0100 Subject: [PATCH] [Oztechan/CCC#4100] Add Logs for banner ad failed requests for iOS --- .../UI/Components/AdaptiveBannerAdView.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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) }) + } + } }