Skip to content

Commit a51b992

Browse files
committed
handle when no icon is returned ios
1 parent 5b00a87 commit a51b992

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

ios/RNGADNativeView.m

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,25 @@ - (void)adLoader:(GADAdLoader *)adLoader didReceiveUnifiedNativeAd:(GADUnifiedNa
331331
}
332332

333333

334+
334335
[dic setObject:images forKey:@"images"];
335-
[dic setValue:[nativeAd.icon.imageURL absoluteString] forKey:@"icon"];
336+
if (nativeAd.icon != nil) {
337+
[dic setValue:[nativeAd.icon.imageURL absoluteString] forKey:@"icon"];
338+
} else {
339+
340+
NSString * someString = nativeAd.responseInfo.adNetworkClassName;
341+
NSLog(@"%@", someString);
342+
343+
if ([nativeAd.responseInfo.adNetworkClassName isEqualToString:@"GADMAdapterGoogleAdMobAds"]) {
344+
[dic setValue:@"noicon" forKey:@"icon"];
345+
} else {
346+
[dic setValue:@"empty" forKey:@"icon"];
347+
}
348+
349+
350+
}
351+
352+
336353
[dic setValue:nativeAd.starRating forKey:@"rating"];
337354

338355
self.onUnifiedNativeAdLoaded(dic);

src/IconView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ const IconView = (props) => {
2020
_onLayout();
2121
}, [nativeAd, nativeAdView]);
2222

23-
return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" ? (
23+
return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" && nativeAd !== "noicon" ? (
2424
<Image
2525
{...props}
2626
resizeMode="cover"
2727
ref={iconViewRef}
2828
onLayout={_onLayout}
2929
source={{ uri: nativeAd.icon }}
3030
/>
31-
) : nativeAd && nativeAd.icon && nativeAd.icon !== "noicon" ? null : (
31+
) : nativeAd && nativeAd.icon && nativeAd.icon === "noicon" ? null : (
3232
<Image
3333
{...props}
3434
resizeMode="cover"

0 commit comments

Comments
 (0)