Hi
We have been using Google-Mobile-Ads-SDK < 7.48.0 without any issue with Fluid size ads.
Ever since upgraded to >= 7.48, the size delegate always returns 0 height.
We have a setup to use the Ad in a table view, so when the ad is fetched, we added to an off-screen container view and laid it out with auto layout without constraining the height. When the 5th table view cell is loaded, we add the adview to the table view cell.
See the code below to see our setup. Please help, thanks in advance.
Wei
func fetchNewAd() {
configureAdViewAndRequest()
let targetingData = configuration.adCustomTargeting
adRequest?.customTargeting = targetingData
adView?.load(adRequest)
}
func configureAdViewAndRequest() {
let adView = DFPBannerView(adSize: configuration.adSize)
let adRequest = DFPRequest()
adView.enableManualImpressions = true
adView.delegate = self
adView.adSizeDelegate = self
// set the width of `adView`. adView will decide what's the height
configuration.configAdViewFrame(adView)
adView.rootViewController = rootViewController
adView.adUnitID = configuration.adUnitID
self.adRequest = adRequest
self.adView = adView
}
extension SearchResultPageAdFetcher: GADBannerViewDelegate {
func adViewDidReceiveAd(_ bannerView: GADBannerView) {
// The ad view needs to be added to the root view controller's view hiriechy and layed out to get the correct size.
if let adView = self.adView {
adView.configureForAutoLayout()
adContainerView.addSubview(adView)
adView.autoPinEdgesToSuperviewEdges(with: .zero, excludingEdge: .bottom)
adContainerView.layoutIfNeeded()
}
}
}
extension SearchResultPageAdFetcher: GADAdSizeDelegate {
func adView(_ bannerView: GADBannerView, willChangeAdSizeTo size: GADAdSize) {
if let adView = self.adView {
adView.resize(size)
}
}
}
|
||||||
Do you need to use the extensions?
What happens if you just try to pass the arguments into the function.
I would also just suggest to follow our walk through as shown above and then build out the TableView with that.
|
||||||
The team provided their feedback and mentioned that fluid ads loaded through GADAdLoader are unsupported now. You can either choose some fixed ad size or to load a fluid banner through DFPBannerView directly.
|
||||||
|
||||||