Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IOS] Multiple ads on 1 screen #301

Open
luongminh2410dev opened this issue Aug 12, 2022 · 13 comments
Open

[IOS] Multiple ads on 1 screen #301

luongminh2410dev opened this issue Aug 12, 2022 · 13 comments

Comments

@luongminh2410dev
Copy link

luongminh2410dev commented Aug 12, 2022

I use 2 NativeAdView at top and bottom on 1 screen, so if it show the same ads -> NativeMediaView of top-ads return blank.

I check firebase-analyst and only see bottom-ads be counted

Android working perfectly

My code:
- Ads repository init (on loading screen)

await AdManager.registerRepository({
    name: 'top_detail_admob',
    adUnitId: rn_admob_detail_top,
    expirationPeriod: 2 * 60 * 60 * 1000,
    adChoicesPlacement: 'topRight',
    numOfAds: 3,
})
await AdManager.registerRepository({
    name: 'bottom_detail_admob',
    adUnitId: rn_admob_detail_bottom,
    expirationPeriod: 2 * 60 * 60 * 1000,
    adChoicesPlacement: 'topRight',
    numOfAds: 3,
})

- Ads component

const NativeAdvanceAds = (props) => {
    const { repository } = props;
    const [visible, setVisible] = useState(true);
    const [adContent, setAdContent] = useState(null);
    const refNativeAdView = useRef();
    const AD_MEDIA_WIDTH = Metrics.DEVICE_WIDTH - Metrics.HOME_MARGIN_ITEM * 2;
    const AD_MEDIA_HEIGHT = adContent?.aspectRatio ? AD_MEDIA_WIDTH / adContent.aspectRatio : 0;
    const onFailed = message => {
        console.log(message)
        setVisible(false)
    }
    const onNativeAdLoaded = (content) => {
        setAdContent(content)
    }
    useEffect(() => {
        refNativeAdView.current?.loadAd();
    }, [])
    if (!visible || !repository) return null;
    return (
        <NativeAdView
            ref={refNativeAdView}
            repository={repository}
            onAdFailedToLoad={onFailed}
            onNativeAdLoaded={onNativeAdLoaded}
            refreshInterval={60000 * 2}
            enableTestMode={__DEV__}
            style={styles.admob}>
            {
                !isNullOrEmpty(adContent) &&
                <View style={styles.admob_body}>
                    <View style={styles.admob_content}>
                        <View style={styles.admob_header}>
                            <IconView
                                resizeMode="contain"
                                style={styles.admob_icon}
                            />
                            <View style={styles.admob_header_right}>
                                <HeadlineView style={styles.admob_headerline} />
                                <TaglineView
                                    numberOfLines={2}
                                    style={styles.admob_tagline}
                                />
                                {
                                    adContent?.advertiser ?
                                        <AdvertiserView numberOfLines={1} style={styles.admob_advertiser} />
                                        : null
                                }
                                <View style={styles.admob_store}>
                                    {adContent?.store ? <StoreView style={styles.admob_store_view} /> : null}
                                    {
                                        adContent?.rating != 0 ?
                                            <StarRatingView
                                                starSize={12}
                                                fullStarColor="orange"
                                                emptyStarColor="gray"
                                                style={styles.admob_star_rating}
                                            />
                                            : null
                                    }
                                </View>
                            </View>
                        </View>
                        {
                            adContent?.images ?
                                <NativeMediaView
                                    style={[styles.media_view, {
                                        width: AD_MEDIA_WIDTH,
                                        height: AD_MEDIA_HEIGHT
                                    }]}
                                    muted
                                />
                                : null
                        }
                        {
                            adContent?.callToAction ?
                                <CallToActionView
                                    style={styles.action_view}
                                    buttonAndroidStyle={styles.action_view_android}
                                    allCaps
                                    textStyle={styles.action_view_txt}
                                />
                                : null
                        }
                    </View>
                    <AdBadge
                        style={styles.admob_badge}
                        textStyle={styles.admob_badge_txt}
                    />
                </View>
            }
        </NativeAdView>
    )
}
@luongminh2410dev luongminh2410dev changed the title [BUG] Multiple ads on 1 screen (IOS) [IOS] Multiple ads on 1 screen Aug 12, 2022
@dorthwein
Copy link

we're running into this as well.

@ameerarx
Copy link

we're running into this as well.

how did you decide?

@anhvd-iKong
Copy link

you can create a ref for NativeAdvanceAds and call loadAd again for this.

@ajpaulingalls
Copy link

You can reproduce this by simply changing media to true in the example app list view:

line 23 of /example/src/list.js
<AdView loadOnMount={false} index={index} type="image" media={true} />

Not sure why this is happening, but its a real problem on iOS...

@dorthwein
Copy link

I think the core issue is having 2 ads displaying with the same adUnit but loading at different times. Obviously a work around would be different ad units but that problematic.

@ajpaulingalls
Copy link

I think the core issue is having 2 ads displaying with the same adUnit but loading at different times. Obviously a work around would be different ad units but that problematic.

My experience happens even if the ad units are different...

@retireearly
Copy link

how was this fixed?

@yaminichhabra
Copy link

Any update on this ? how can I fix this ?

@absolutezero13
Copy link

still no solution for this?

@ducpt-bili
Copy link

ducpt-bili commented Jan 28, 2024

+1 for the issue, on android ads video not showing player when test single video ad, on the ios, the List ads is not work well, it crash sometime when i first build app and it maybe can not disply ads media. Please check image below. I just try to run your example on git.

Screenshot 2024-01-28 at 12 20 24 ![Simulator Screenshot - iPhone 15 - 2024-01-28 at 12 21 02](https://github.com/ammarahm-ed/react-native-admob-native-ads/assets/101504153/78263ec4-6e62-4ae7-b609-8829ed4ea960)

@ducpt-bili
Copy link

I just foundout NativeMediaView is the problem, but right now i don't have time to invest on the issue. I decide to just using ImageView on my app to display ads with image. Not using video ad yet for the above issue.

@ammarahm-ed
Copy link
Owner

Showing more than one ad on visible screen is against admob policies.

@luongminh2410dev
Copy link
Author

Showing more than one ad on visible screen is against admob policies.

I can't find any information about that. It seems this does not violate admob policies @ammarahm-ed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants