This page will store any utilities that can used in conjuntion with the Prebid SDK.
Prebid SDK provides a function findPrebidCreativeSize to address a bug in the Google Ad Manager ad server (described in this Google forum thread) where under certain situations ads fail to render.
For GAM banner integrations, call findPrebidCreativeSize from onAdLoaded after each successful banner load. The utility searches the creative’s HTML for Prebid size information. If found, use the success callback to resize the ad view accordingly. Size resolution may fail when GAM serves a non-Prebid creative or when the required size information cannot be extracted from a Prebid creative. The failure callback does not distinguish between these cases; leave the ad view’s current size unchanged.
findPrebidCreativeSize is supported on Android API versions 19+. Using on earlier versions is safe to use, however the resizing would not function.Usage example:
adView.adListener = object : AdListener() {
override fun onAdLoaded() {
super.onAdLoaded()
AdViewUtils.findPrebidCreativeSize(adView, object : AdViewUtils.PbFindSizeListener {
override fun success(width: Int, height: Int) {
// Resize the ad view using the resolved Prebid creative size.
adView.setAdSizes(AdSize(width, height))
}
override fun failure(error: PbFindSizeError) {
// Size resolution may fail for a non-Prebid creative served by GAM,
// or when size information cannot be extracted from a Prebid creative.
}
})
}
}