Skip to content

Commit

Permalink
[#4100] Add Logs for banner ad failed requests for iOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaozhan committed Nov 30, 2024
1 parent 1ada808 commit 89eb729
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ios/CCC/UI/Components/AdaptiveBannerAdView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import GoogleMobileAds
import SwiftUI
import UIKit
import Provider

struct AdaptiveBannerAdView: UIViewControllerRepresentable {
private var unitID: String
Expand All @@ -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)

Expand All @@ -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) })
}
}
}

0 comments on commit 89eb729

Please sign in to comment.