From a51b992c862b53b807c9289472b08a547bf6c6d4 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Thu, 9 Jul 2020 13:14:22 +0500 Subject: [PATCH] handle when no icon is returned ios --- ios/RNGADNativeView.m | 19 ++++++++++++++++++- src/IconView.js | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ios/RNGADNativeView.m b/ios/RNGADNativeView.m index 2baf3a61..f0593e3c 100755 --- a/ios/RNGADNativeView.m +++ b/ios/RNGADNativeView.m @@ -331,8 +331,25 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveUnifiedNativeAd:(GADUnifiedNa } + [dic setObject:images forKey:@"images"]; - [dic setValue:[nativeAd.icon.imageURL absoluteString] forKey:@"icon"]; + if (nativeAd.icon != nil) { + [dic setValue:[nativeAd.icon.imageURL absoluteString] forKey:@"icon"]; + } else { + + NSString * someString = nativeAd.responseInfo.adNetworkClassName; + NSLog(@"%@", someString); + + if ([nativeAd.responseInfo.adNetworkClassName isEqualToString:@"GADMAdapterGoogleAdMobAds"]) { + [dic setValue:@"noicon" forKey:@"icon"]; + } else { + [dic setValue:@"empty" forKey:@"icon"]; + } + + + } + + [dic setValue:nativeAd.starRating forKey:@"rating"]; self.onUnifiedNativeAdLoaded(dic); diff --git a/src/IconView.js b/src/IconView.js index a53a2188..4328ec27 100644 --- a/src/IconView.js +++ b/src/IconView.js @@ -20,7 +20,7 @@ const IconView = (props) => { _onLayout(); }, [nativeAd, nativeAdView]); - return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" ? ( + return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" && nativeAd !== "noicon" ? ( { onLayout={_onLayout} source={{ uri: nativeAd.icon }} /> - ) : nativeAd && nativeAd.icon && nativeAd.icon !== "noicon" ? null : ( + ) : nativeAd && nativeAd.icon && nativeAd.icon === "noicon" ? null : (