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

NativeAdView is not loading properly.

Open CygnetUrvashi opened this issue 1 year ago • 1 comments

I am using NativeAdView in react-native my ad component . And its not reflecting / removed after some time.This is a random issue which i am facing . below is my code.

useEffect(() => { if (repositoryName && repositoryName?.length > 0) { loadAd(); } else { debounceForFunc(() => { if (blankFeedImages.length > 0) { setDummyUri(blankFeedImages[Math.floor(Math.random() * blankFeedImages.length)]); } }, 3000); } }, [repositoryName]);

return ( <ImageBackground source={{ uri: uri || dummyUri }} style={{ width: Dimensions.get("window").width, height, backgroundColor: colors.black, }} onLoad={() => { if (dummyUri) { setShowLoader(false); } }} onError={() => setShowLoader(false)} blurRadius={uri ? 15 : 0} > <View style={{ height }}> {repositoryName && currentRepository?.current ? ( <NativeAdView ref={nativeAdViewRef as MutableRefObject<NativeAdView>} enableTestMode={env === "dev" || env === "qa"} repository={currentRepository.current || undefined} style={styles.container} onNativeAdLoaded={(ad: NativeAd) => { setShowLoader(false); appLogger.warn("Ad Loaded", ad); setUri(ad?.images?.[0]?.url); setDummyUri(undefined); currentAdJSON.current = ad; setLoaded(true); trackEvent({ eventName: Events.nativeAdLoaded, eventData: ad }); }} onAdImpression={() => { trackEvent({ eventName: Events.nativeAdImpression, eventData: currentAdJSON, }); }} onAdFailedToLoad={(error: any) => { setShowLoader(false); setUri(null); appLogger.error("Failed to load ad", error); trackEvent({ eventName: Events.nativeAdError, eventData: error, }); }} > <View style={{ height: height, width: Dimensions.get("window").width, }} > {currentItemId === post.id ? ( <ImageView style={{ width: Dimensions.get("window").width, height: "40%", marginTop: 150, }} /> ) : ( <View style={{ width: Dimensions.get("window").width, height: "70%", }} /> )} <View style={{ width: Dimensions.get("window").width, alignItems: "center", }} > <View style={[styles.footerView]} testID="attributesView"> <View style={{ marginBottom: 5 }}> <IconView testID="iconView" style={styles.icon} /> <HeadlineView style={styles.postDescriptionText} numberOfLines={1} /> <TaglineView style={styles.descriptionViewLarge} numberOfLines={2} /> {uri ? ( <CallToActionView style={styles.cta} textStyle={styles.ctaText} /> ) : null} </View> </View> </View> {showLoader ? ( <ActivityIndicator size={"small"} style={{ position: "absolute", top: 0, bottom: 0, left: 0, right: 0 }} color={colors.blue} /> ) : null} </View> </NativeAdView> ) : null}

    <AdBadge style={styles.adTextView} textStyle={styles.adTextStyle} />
  </View>
</ImageBackground>

);

Note : Its working fine with "ImageView" . But i cant use it as i want serve video ads as well. Can you please help me out?

"react-native": "0.71.13", "react-native-admob-native-ads": "0.6.6",

CygnetUrvashi avatar Apr 23 '24 11:04 CygnetUrvashi