How to add mediumRectangle ads using PublisherBanner
Hi,
Here is the piece of code which I'm using to display ads.
<PublisherBanner onAdFailedToLoad={error => console.log(error)} adSize="banner" style={{ height: 400 , width: '100%' }} adUnitID="/6499/example/banner" testDeviceID="EMULATOR" />
but only largeBanner and banners are working, I want to add mediumRectangle (300X250).
When I use that in adSize, it is showing me -
Error: The ad request was successful, but no ad was returned due to lack of ad inventory
Also for mediumRectangle is there any test unit id ?
Please help me out,
Thank you.
there are many reasons to get this error.
- if you are testing with simulator, generally there are very limited ads to display, so we will get this error. but this will work in production.
- If you have created your ad units newly, so that will take some time to become active for serving ads, generally it will take 3 - 5 days to get active, so please wait and have fun.
- there will be some cases that you will keep some restrictions on serving ads like only display amount more than certain amount, that time ads may not be available for serving the same. so keep your ad settings always in an optimised manner.
i think these are the possible causes. let me know if you need any other info.
<PublisherBanner
style={sizeOfPublicity}
adSize="mediumRectangle"
validAdSizes={[
'banner',
'smartBannerPortrait',
'largeBanner',
'mediumRectangle',
]}
adUnitID={__DEV__ ? '/6499/example/banner' : publicidade[currentApp]}
testDevices={[PublisherBanner.simulatorId]}
didFailToReceiveAdWithError={e => {
setSizeOfPublicity(defaultSizes);
console.log('Banner:onAdFailedToLoad', e);
}}
onAdLoaded={({width, height}) => {
setSizeOfPublicity({height, width});
console.log('Banner:onAdLoaded');
}}
onAdFailedToLoad={e => {
setSizeOfPublicity(defaultSizes);
console.log('Banner:onAdFailedToLoad', e);
}}
onAdOpened={() => console.log('Banner:onAdOpened')}
onAdClosed={() => console.log('Banner:onAdClosed')}
onAdLeftApplication={() => console.log('Banner:onAdLeftApplication')}
onAppEvent={event => console.log('Banner:onAppEvent', event)}
/>