Skip to content

Commit

Permalink
handle when no icon is returned ios
Browse files Browse the repository at this point in the history
  • Loading branch information
ammarahm-ed committed Jul 9, 2020
1 parent 5b00a87 commit a51b992
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion ios/RNGADNativeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/IconView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ const IconView = (props) => {
_onLayout();
}, [nativeAd, nativeAdView]);

return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" ? (
return nativeAd && nativeAd.icon && nativeAd.icon !== "empty" && nativeAd !== "noicon" ? (
<Image
{...props}
resizeMode="cover"
ref={iconViewRef}
onLayout={_onLayout}
source={{ uri: nativeAd.icon }}
/>
) : nativeAd && nativeAd.icon && nativeAd.icon !== "noicon" ? null : (
) : nativeAd && nativeAd.icon && nativeAd.icon === "noicon" ? null : (
<Image
{...props}
resizeMode="cover"
Expand Down

0 comments on commit a51b992

Please sign in to comment.