BannerAd.onResize
Listen for the banner ad actual size change event.
The dimensions provided by the callback match style.realWidth / style.realHeight and are in logical pixels (dp on Android, pt on iOS), with no need to multiply or divide by pixelRatio. See sud.getContainerInfo for details.
The actual size is reported for the first time after the ad is really displayed, and after that only when the actual size changes. No notification is sent when the ad loads successfully but is not displayed, when the display fails, when the actual size is unchanged, or when only the position changes.
A resolved show() Promise does not mean the ad was really displayed. Still call BannerAd.show() after the BannerAd.onLoad() notification instead of waiting for onResize. onResize only reports the actual size; it never triggers a display and never replaces BannerAd.onLoad().
Parameters
function listener
Listener for the actual size change event.
Parameters
Object res
| Property | Type | Description |
|---|---|---|
| width | number | Actual ad width in logical pixels, matching style.realWidth |
| height | number | Actual ad height in logical pixels, matching style.realHeight |
Example Code
bannerAd.onResize((res) => {
// res.width / res.height match bannerAd.style.realWidth / realHeight and can be used to adjust the game UI around the ad.
console.log(res.width);
console.log(res.height);
});