react-native-admob
react-native-admob copied to clipboard
Invalid width or height in AdmobBanner
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)
+1
Any solution for this please? I am stuck here for over 1 week,
+1
+1
+1
+1
+1
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
I fixed it with comment some lines;
RNAdmobBanner.js -> line 43;
handleAdFailedToLoad(event) {
//if (this.props.onAdFailedToLoad) {
// this.props.onAdFailedToLoad(createErrorFromErrorData(event.nativeEvent.error));
//}
}
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)
@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 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
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.
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.
Please check the admob id and unit id. And check the payment status of admob account.