NZME / react-native-ad-manager

Google Ad Manager bridge for React Native
MIT License
52 stars 61 forks source link

Seeking suggestion: To display banner ads at regular intervals in a feed list, which is an infinitely paginated flat list #116

Open AppalaNaidu01 opened 11 months ago

AppalaNaidu01 commented 11 months ago

This is not a bug; I am seeking suggestions on how to integrate ads into a React Native project with the following requirements:

I have an infinitely scrollable flat list of feed items, similar to Instagram, where I need to display banner ads at regular intervals. This involves handling scenarios such as:

  1. If an Ad request succeeds for a specific index - Display the Ad at the index
  2. If an Ad request fails for a specific index - Display the next feed item rather than displaying a Placeholder/Empty view
  3. If an Ad request fails because of timeout error - Display the next feed item
  4. If the index where an Ad should be displayed is scrolled before receiving a successful response for the ad request - Display the next feed item
    • But if the index where the Ad isn't displayed because of the delayed response should be displayed if the user scrolls up to that index again.

The approach I am thinking of at the moment: I thought that the solution for the above use cases is to pre-fetch the banner ad view object before displaying it. But, because the Banner Ad is a component in this SDK, I should only be able to load the Ad(make an Ad request) after mounting the component into the screen or flat list. However, with this approach, I wasn't able to handle the failure cases.

But with the above approach, I need to find a way to pre-fetch the banner ad object.

Can you please help me by sharing any better approach you can think of? Or can you please help me with improving my approach to implement this?

mark-okiki commented 6 months ago
  1. Use the Android ViewHolder pattern to get the item viewtype and choose to render the list Item or ad.
  2. Calculate or set the NativeAd's height if the ad loads successfully
  3. Set the height of the NativeAd to 0 id the ad fails

I don't see how you can prefetch the ad