ammarahm-ed / react-native-admob-native-ads

A simple and robust library for creating & displaying Admob Native Advanced Ads in your React Native App using Native Views.
https://ammarahm-ed.github.io/react-native-admob-native-ads/docs/introduction/
MIT License
397 stars 134 forks source link

Update for Google-Mobile-Ads-SDK v11 #378

Closed dev-arekusandoru closed 2 weeks ago

dev-arekusandoru commented 1 month ago

Hello, there is not one specific issue that I am addressing, but I would like to request that you update the entire package to work with the latest version of the Google-Mobile-Ads-SDK.

I have been trying to figure out a way to get this package working in my latest Expo project (SKD 51), and has been quite impossible so far. Here are some things I have noticed that have made the process more confusing and difficult.

  1. The documentation appears to be outdated, suggesting the use of the Google-Mobile-Ads-SDK v9. The documentation is also very scarce. Please update this, and it would also be helpful to indicate where in the podfile the pod line needs to be added.
  2. Update the package version on npm. There have been fixes pushed to the master branch related to issue #359 , but they are only accessible by installing with the command npm i ammarahm-ed/react-native-admob-native-ads,
  3. With the most recent version of the code, the build error is fixed but after building and installing a development build on iOS, the build will crash on launch, with no errors given.
  4. Because the code and documentation are relying on an outdated version of the Google-Mobile-Ads-SDK, there is conflict when using this package in tandem with the react-native-google-mobile-ads package.

I hope this issue is addressed quickly, as I would love to use this package in my project! Please let me know if you would like any further clarification of any of the points I have listed above.

zoobibackups commented 1 month ago

this package is not compatible with latest admit-version. and react-native-google-mobile-ads

SumitR9910 commented 3 weeks ago

this package is not compatible with latest admit-version. and react-native-google-mobile-ads

Is this package, still working for anyone of you?

are there any alternatives to implementing native ads into a react native app, as this package does not seem to be maintained anymore, facing too many errors in order to get it to work.

dev-arekusandoru commented 3 weeks ago

@SumitR9910 I was able to get this working in my project. here is how.

  1. npm install react-native-mobile-ads
  2. add plugin
    1. Important: add plugin under expo.plugins, not expo.extra.plugins
  3. npx expo prebuild
  4. add pod 'Google-Mobile-Ads-SDK' to Podfile
    1. right after target … do
  5. add to info.plist from https://developers.google.com/admob/ios/quick-start#update_your_infoplist
  6. cd ios
  7. pod install —repo-update
  8. add changes from https://github.com/ammarahm-ed/react-native-admob-native-ads/commit/c4cc493e392445b153debd7d07f80ebc16ba053e
    1. add changes to package
    2. npx patch-package react-native-admob-mobile-ads
  9. create development/production build
SumitR9910 commented 3 weeks ago

Thanks for the response.

I was actually able to successfully build through eas when I installed the package through ammarahm-ed/react-native-admob-native-ads#master. But after successfully building, I was thrown this new error 'error while updating property 'requestnonpersonalizedadsonly' of a view managed by : rngadnativeview' #374

Is this patch meant to solve that?

dev-arekusandoru commented 3 weeks ago

@SumitR9910 no, i never encountered that error.

looking at the issue you linked, i am guessing you are building for android? i only build for iOS. however, i saw that this commit was mentioned as a fix. try implementing this change and using patch-package again, and let me know if that works

SumitR9910 commented 3 weeks ago

@dev-arekusandoru I did actually try this, but the error still persists.

Yes, I am building for Android. Is it working fine for you on iOS, are you able to fetch ads or test ads?

dev-arekusandoru commented 3 weeks ago

@SumitR9910 sorry but i don't know how to help that. I am currently working only on the ios build right now, but when i start working on android i will let you know what I figure out.

and yes, iOS works perfectly for now. I am only fetching test ads since my app is not yet on the app store, but i expect it will work as expected with real ad fetching

SumitR9910 commented 3 weeks ago

Great to know its working on iOS, maybe a fresh installation might help with the issues.

Will also let you know if I eventually end up with a solution to this.

zoobibackups commented 3 weeks ago

@dev-arekusandoru @SumitR9910 @rogerkerse @Nox04 can we work together to develop a new version of this library. was I think this is currrently not maintained.

SumitR9910 commented 3 weeks ago

@zoobibackups don't have much experience with these kind of packages, as i am fairly new to mobile development and react native, but will try my best to help you guys out if you plan on creating a new version of this library. As i too think this library is no longer maintained.

MamoshiSE commented 3 weeks ago

I haven't been able to get rid of the error: 'error while updating property 'requestnonpersonalizedadsonly' of a view managed by : rngadnativeview' either, tried all different methods that were suggested in the issues by people. Have patched the package in multiple ways.

If i keep requestnonpersonalizedadsonly in the pre registring of the ads, then it throws the error: RNAdmobNativeAdsManager.registerRepository and if I remove it it throws: 'error while updating property 'requestnonpersonalizedadsonly'

Does anyone have any idea on how to solve this?

SumitR9910 commented 3 weeks ago

@MamoshiSE are you registering repositories for the respective ad type (image or video) along with initialising the ad manager in your entry file?

MamoshiSE commented 3 weeks ago

Hey here is how it looks when initizaling it:

AdManager.registerRepository({ name: 'clipFeedNativeAd', adUnitId: adUnitNativeId, numOfAds: 20, nonPersonalizedAdsOnly: false, mediationEnabled: true, mediationOptions: { nativeBanner: true, }, expirationPeriod: 3600000, // in milliseconds (optional) })

Then when calling it: `<NativeAdView ref={nativeAdRef} refreshInterval={60000 * 2} onNativeAdLoaded={onNativeAdLoaded} videoOptions={{ customControlsRequested: true, }} repository={"clipFeedNativeAd"}

`

ammarahm-ed commented 2 weeks ago

Fixed in v0.7.1.

AftabUfaq commented 2 weeks ago

can you add an exmaple of preloaded ads. and i want if a state change the preloaded adds must change