Fluid size returns height 0 in sizeDelegate

188 views
Skip to first unread message

Wei Zhang

unread,
Sep 29, 2020, 12:37:37 PM9/29/20
to Google Mobile Ads SDK Developers

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)

        }

    }

}


Mobile Ads SDK Forum Advisor Prod

unread,
Sep 29, 2020, 4:05:14 PM9/29/20
to vee...@gmail.com, google-adm...@googlegroups.com
Hi Wei,

Thank you for bringing this to our attention. I was able to look over our documentation here . As well as also looking at how to handle the GADAdSizeDelegate which I see here how we implement it.

Would seem that the table might not be getting the ad correctly. Do you need to use the extensions? What happens if you just try to pass the arguments into the function. From what I can tell it would seem you are not getting the adView to show at all. I would also just suggest to follow our walk through as shown above and then build out the TableView with that. 

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q25XnUA:ref

Wei Zhang

unread,
Sep 29, 2020, 4:59:10 PM9/29/20
to Mobile Ads SDK Forum Advisor Prod, google-adm...@googlegroups.com
Hi William,
Thanks for getting back to me.

Do you need to use the extensions? 
Implementing the delegate on an extension is equivalent to implement on the class itself. That's just how we organize codes. 

What happens if you just try to pass the arguments into the function. 
What do you mean?

I would also just suggest to follow our walk through as shown above and then build out the TableView with that. 
The same implementation was working before we bump the version to 7.48. But I will try from scratch again and will let you know what it goes.


--
Wei Zhang

Mobile Ads SDK Forum Advisor Prod

unread,
Sep 30, 2020, 12:55:22 AM9/30/20
to vee...@gmail.com, google-adm...@googlegroups.com
Hi Wei,

I work along with William. Allow me to assist you in this.

With regard to passing the arguments into the function, I think that my colleague means here is to implement the delegate on the class itself instead of using extensions. However, it appears this is just the same implementation and it will not affect the SDK behavior. 

On the other hand, I've tried our sample API demo app, and I wasn't able to reproduce the issue on my end. Could you kindly try our sample app, then check if the occurs on your end? In addition, could you use the latest version of the SDK (7.66.0)?

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 
 

ref:_00D1U1174p._5004Q25XnUA:ref

Wei Zhang

unread,
Sep 30, 2020, 11:17:20 AM9/30/20
to Mobile Ads SDK Forum Advisor Prod, google-adm...@googlegroups.com
Hi Teejay,
I upgraded to the latest SDK and it still doesn't work.

I have looked at all the sample apps, none of them applies to our need, which is Fluid size Ad.
I also quote your reply to another thread:
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.

Does the highlighted part contribute to the problem of 0 height that I got in the GADAdSizeDelegate ?
Thanks
--
Wei Zhang

Mobile Ads SDK Forum Advisor Prod

unread,
Sep 30, 2020, 12:34:52 PM9/30/20
to vee...@gmail.com, google-adm...@googlegroups.com
Hi Wei,

Thank you for your response back regarding this. Would it be possible for you to also send us a sample of your app without any business logic to us. Using the same implementation and ad loading as you have in your app. So that we can look further into what could be causing this issue.

Regards,
Google Logo
William Pescherine
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q25XnUA:ref
Message has been deleted

Mobile Ads SDK Forum Advisor Prod

unread,
Oct 2, 2020, 12:31:15 AM10/2/20
to vee...@gmail.com, google-adm...@googlegroups.com
Hi Wei,

Thank you for getting back to us.

I tested your app, and I was able to load the ad using our test Ad Unit ID. However, the fluid size returns 0 height when using your live Ad unit ID. It appears that the issue is on creative rather than anything specific to the Mobile Ads SDK implementation. I'm afraid that creative specific issues is out of scope to our team. That said, we would recommend reaching out to Google Ad manager team. The product specialist there would be able to assist you further regarding this.

As an aside, I have to mask your post as it contains sensitive information. Please refrain from posting sensitive information like Ad Unit ID in the forum. Moving forward, if you want to share anything with us, you can use the "Reply Privately to Author" option to share the details privately. Below is the copy of your post scrubbed.

Hi William,
I have prepared a sample shows how we set up the Ads.
I have no issue to load and render the "/6499/example/native".
But our own ad is returning height 0 in the size delegate. Can you help me find out why? It could be something wrong with how our Ad is set up on the DFP managing side.
Thanks,
Wei
 
The following snippet shows how to switch between google ad and our ad. 
if useGoogleTestAd {
     adView.adUnitID = "/6499/example/native"
else {
      adView.adUnitID = "xxx/xxx/xxxxx"
     // To return a test Ad.
     adRequest.customTargeting = ["env": "dev"]
}

Regards,
Google Logo
Teejay Wennie Pimentel
Mobile Ads SDK Team
 


ref:_00D1U1174p._5004Q25XnUA:ref
Reply all
Reply to author
Forward
0 new messages