react-native-admob icon indicating copy to clipboard operation
react-native-admob copied to clipboard

Invalid width or height in AdmobBanner

Open tahakhozooie opened this issue 5 years ago • 15 comments

Hi

AdmobBanner show error Invalid width or height(0 , 0) width real ad-unit-id, but it's work with test id! (my platform is ios 12 and i'm using last version of this library beta-5)

tahakhozooie avatar Mar 13 '19 12:03 tahakhozooie

+1

TylerIlunga avatar Mar 21 '19 06:03 TylerIlunga

Any solution for this please? I am stuck here for over 1 week,

bosz avatar Apr 11 '19 14:04 bosz

+1

shniu avatar Apr 24 '19 10:04 shniu

+1

quangvo09 avatar May 24 '19 05:05 quangvo09

+1

dondonjang avatar May 24 '19 21:05 dondonjang

+1

khuyendev avatar Jun 11 '19 02:06 khuyendev

+1

gmsgowtham avatar Jun 19 '19 08:06 gmsgowtham

I fixed it this way - forked the repo and commented out error processing code:

react-native-admob/ios/RNGADBannerView.m:

/// Tells the delegate an ad request failed.
- (void)adView:(__unused GADBannerView *)adView
didFailToReceiveAdWithError:(GADRequestError *)error
{
    /// hide error
    /// if (self.onAdFailedToLoad) {
    ///     self.onAdFailedToLoad(@{ @"error": @{ @"message": [error localizedDescription] } });
    /// }
}

https://github.com/pavelbely/react-native-admob/blob/5cf47d6554ad00f56743720bd961317ce1ef593c/ios/RNGADBannerView.m#L85-L93

You can create your own fork or feel free to use mine :slightly_smiling_face: yarn add https://github.com/pavelbely/react-native-admob

pavelbely avatar Jun 26 '19 07:06 pavelbely

I fixed it with comment some lines;

RNAdmobBanner.js -> line 43;

handleAdFailedToLoad(event) {
  //if (this.props.onAdFailedToLoad) {
  //  this.props.onAdFailedToLoad(createErrorFromErrorData(event.nativeEvent.error));
  //}
}

AlicanAkyol avatar Jul 16 '19 03:07 AlicanAkyol

I didn't have the RNAdmobBanner.js that AlicanAkyol wrote.

I "fixed" the error with PavelBely his comment in the react-native-admob/iOS/RNGADBannerView.m file. Not sure what is causing this because the test ad is working. Will see if the production app also shows the right ads or that they fail to load (and are causing this issue)

Tinmania2018 avatar Jan 11 '20 10:01 Tinmania2018

@pavelbely isn't silencing the error not solving the real problem that is the size being fed to the banner is too small? I just tried your library and this still doesn't work on iphone X devices someone is sending that the banner is too small.... This isn't working in production released apps on IOS as far as I can tell no matter how much I increase the size of the container.

sdb1228 avatar Apr 02 '20 13:04 sdb1228

@sdb1228 you're probably right, it might just swallow the error and simply not display any ad. But in my case that was quick dirty fix specifically for iOS. For Android I use react-native-firebase, but I had some issues with it in iOS

pavelbely avatar Apr 02 '20 15:04 pavelbely

Ill have to check that out tonight. I would much rather have a fix for this library given how nice it has worked for me but I don't love losing money because a banner ad won't show on ios on iphone Xs. Ill see if I can find some time to dive into it but I have about 0 knowledge about how all these things tie together lol.

sdb1228 avatar Apr 02 '20 15:04 sdb1228

I encountered the same error message. The problem was that the banner ad was ultimately being hidden. So I delayed loading the AdMob component for a few seconds and the error went away.

die20 avatar Aug 14 '20 15:08 die20

Please check the admob id and unit id. And check the payment status of admob account.

MinJerry1129 avatar Mar 30 '21 14:03 MinJerry1129