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

add Ad repository feature #216

Merged
merged 39 commits into from
Oct 13, 2021
Merged

Conversation

Ali72
Copy link
Contributor

@Ali72 Ali72 commented Sep 26, 2021

Add Ads repository
description:
ads automatically load and keep in the repository and display it immunity when showing native ad view. if the developer declares repositories, he can load ads from the repos instead of a request to the server.

features:

  • Declare different repositories for different types of Ads or different Ad options
  • Repositories can have some options like total ads to load, reload time interval, etc.
  • Auto retry with interval time after the error recived

…admob-native-ads

* 'master' of https://github.com/ammarahm-ed/react-native-admob-native-ads: (190 commits)
  fix typo
  update version to 0.5.0
  update version to 0.4.2
  minor update in docs
  update example
  remove duplicate declaration
  use videoController provided by events in MediaView
  fix paused prop not passed correctly
  render button properly on ios in example
  fix multiple ad loading on ios
  ui update in example app
  update google ads sdk on android to latest.
  remove jcenter from build.gradle
  update dependencies
  Simplify ios imports and fb mediation as option
  chore: format index.d.ts
  fix example ios app crash
  add migrating from 0.4.1
  update docs
  update example app
  ...
* master:
  fix typo
  update version to 0.5.0
  update version to 0.4.2
  minor update in docs
  update example
  remove duplicate declaration
  use videoController provided by events in MediaView
  fix paused prop not passed correctly
  render button properly on ios in example
  fix multiple ad loading on ios
  ui update in example app
  update google ads sdk on android to latest.
  remove jcenter from build.gradle

# Conflicts:
#	android/build.gradle
#	android/src/main/java/com/ammarahmed/rnadmob/nativeads/RNAdmobNativeView.java
#	example/ios/Podfile
#	example/ios/Podfile.lock
#	ios/RNAdMobManager/RNGADNativeView.m
@ammarahm-ed
Copy link
Owner

Hello by ad repository, you mean to preload ads so they are shown immediately when the view mounts? This has been a long awaited feature. Thanks for all the work.

It appears that you continued working on an older pull request #94. How is the implementation different and what have you changed/improved.

Also can you explain how this works and what breaking changes does it include?

@ammarahm-ed ammarahm-ed merged commit 14f9529 into ammarahm-ed:master Oct 13, 2021
@Ali72
Copy link
Contributor Author

Ali72 commented Oct 15, 2021

Hello by ad repository, you mean to preload ads so they are shown immediately when the view mounts? This has been a long awaited feature. Thanks for all the work.

It appears that you continued working on an older pull request #94. How is the implementation different and what have you changed/improved.

Also can you explain how this works and what breaking changes does it include?

Hi, Ammarahm.
The answer to your first question is yes and that means you can preload ads so they are shown immediately when the view mounts.
About pull request #94, I have to say yes and ha-younes72 is my teammate and I mostly work on the IOS part of the project when he works on the android part.
Usage is easy as yours and you just need to create and configure ad repositories (as you see in the example) and use repository name instead of unit Id.
If you don't need the repository for any native ads view in js, you just need to use unit Id like before.
If you use repository instead of unit id (as props of native view in js), Here's its lifecycle of ad:

  1. start to download an ad or download multiple ads and save them in an array inside the memory when you create repositories.
  2. when you use native ad view in js with repository name (inside of unit id), first we check our cached ads inside the repository (which match with input name) to find the latest ad with the lowest show count (number of an ad shown) value.
  3. If our repository is empty or all ads were expired (we can set expired time when we create a repository), it requests for ads to fill up the repository immediately, otherwise, load from the repository and remove repository listeners from native ad view object.
    Note1: If some of the ads were expired and some others were not, it will return non-expired ads and request for new ads to replace with expired ads.
    Note2: It always tries to keep the repository fill with ads.
    Note3: It will stop trying to load ads when facing none handleable errors (like internal errors such as wrong unit id, etc)
    Note4: large repository means the large allocation of memory and you have to beware of the size of your repo. (we tested for 3 repositories and 10 ads each and not faced any problem with our products).

If you have more questions, don't hesitate to ask.
Best regard, Ali

@ammarahm-ed
Copy link
Owner

ammarahm-ed commented Oct 15, 2021

@Ali72 Thanks for the detailed explanation. I really appreciate you working on such an important feature. The question I have is, what happens to the ad after it has been shown and the view gets destroyed?

The ad repository code lacks the fine grain control over ads as we do through NativeAdView. These include mediationOptions, videoOptions and targetingOptions. I think that it would be best to implement these in repostories the same way so we have same functionality everywhere. What are your thoughts?

Lastly what is the purpose of mediationEnabled property when creating a repository?

@Ali72
Copy link
Contributor Author

Ali72 commented Oct 16, 2021

@ammarahm-ed we will add new ads repositories options such as mediation options, video options, targeting options, etc soon.
Base of google ads mob doc on this link, you can not request mediation ads with ad loaders multi ad load option or GADMultipleAdsAdLoaderOptions therefore you have to load them separately. This option does not set for ios right now and I will send a new pull request as a bug fix as soon as possible.

Note : base of this link, if you request more than 5 ads for a repository, AdMob will reduce it to 5, therefore, the ad repository should divide it into multi requests so when finished first request loading it will send the same request to get the rest of the ads to fill up the repository.

Best regard, Ali

@ammarahm-ed
Copy link
Owner

@Ali72 Okay sounds good. I am working on refactoring the android code. So I will add these options on android and hopefully ios too.

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

Successfully merging this pull request may close these issues.

None yet

4 participants