Prebid SDK Utility functions

This page will store any utilities that can used in conjuntion with the Prebid SDK.

Find Prebid Creative Size

Prebid SDK provides a function findPrebidCreativeSize to address a bug in the Google Ad Manager ad server (described here) where under certain situations ads fail to render.

It is recommended all Google Ad Manager integrations resize all ads served based on the winning Prebid creative size findPrebidCreativeSize. Functionally speaking the Prebid SDK resizes ad slots based on the onAdLoaded (when an ad is received) to determine the winning Prehbid ad size to determine how to resize the ad slot.

Usage example:

adView.adListener = object : AdListener() {
    override fun onAdLoaded() {
        super.onAdLoaded()

        // Determine the kind of winning line item
        AdViewUtils.findPrebidCreativeSize(adView, object : AdViewUtils.PbFindSizeListener {
            override fun success(width: Int, height: Int) {

                // In the case of Prebid's line item - resize te ad view
                adView.setAdSizes(AdSize(width, height))
            }

            override fun failure(error: PbFindSizeError) {}
        })
    }
}