React-native-admob: Smart Banner doesn't show

Created on 7 Oct 2017  路  11Comments  路  Source: sbugert/react-native-admob

I tested on a fresh react-native project. All ad sizes display as expected except smart banners.

Using react-native-admob version beta.2 with react-native 0.49.1 on android. ios appears to work fine.

onAdLoaded does fire, but the ad spot is just blank with smart banners.

          <AdMobBanner
            adSize="smartBannerPortrait"
            adUnitID="app-d"
            testDevices={[AdMobBanner.simulatorId]}
            onAdLoaded={() => this.setState({bannerDims:bannerDimsAd})}
            onAdFailedToLoad={() => this.setState({bannerDims:bannerDimsEmpty})}
            />
bug

Most helpful comment

@rizzomichaelg Thanks! That fix works for me.

All 11 comments

I think there鈥檚 missing code here. Does the setState in onAdLoaded define the size of the container? Or what does it do?

Yes it defines the size of the container. Banners show for all other ad sizes with the same code, just not for smart banners.

I just tried without my onadloaded and experienced the same thing with a fresh rn install. All sizes work except smart banners. Are you able to reproduce or is it just me?

same here

+1 here. other sizes work, but smart banners do not.

Looks like the problem is that in RNAdMobBannerViewManager.java this.adView.getAdSize() returns "412x50_as" after the ad has been loaded, so the compare with AdSize.SMART_BANNER fails. The resulting width and height are then -1 and -2 which causes it to fail being displayed.

@rizzomichaelg Thanks! That fix works for me.

smartBannerLandscape and smartBannerPortrait still not working on android.

@artemukolov the pr hasn't been merged yet. You can copy this file into your project until then and it will work.
https://github.com/rizzomichaelg/react-native-admob/blob/21b3dddcc7a5262debe00ff0faf70366b27a0688/android/src/main/java/com/sbugert/rnadmob/RNAdMobBannerViewManager.java

oh, thanks a lot.

This has been fixed on master, a release will follow shortly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

talaikis picture talaikis  路  3Comments

furkancelik picture furkancelik  路  5Comments

jonigl picture jonigl  路  4Comments

thekiwi picture thekiwi  路  4Comments

mattveraldi picture mattveraldi  路  5Comments