invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

[📚] AdMob - use `@invertase/react-native-google-ads` #5329

Closed mmskvortsov closed 2 years ago

mmskvortsov commented 3 years ago

AdMob documentation availability

Hi there! I've noticed that AdMob documentation is not available on the official website: https://rnfirebase.io/admob There is a 404 error:

image

Is there any issue with that or this part of documentation turned off intentionally? Thanks!

mikehardy commented 3 years ago

v11.5.0 was issued while react-native 0.64 existed and should work fine with it @Mikenso yes it will - it took a long long time to get the AppCheck module up but I just finished that work #5581 which was blocking everything since approximately May. A more rapid tempo will resume here now https://github.com/invertase/react-native-firebase/commits/master ...

huseyin39 commented 3 years ago

@Mikenso Which SDK are you talking about? This one "implementation 'com.google.android.gms:play-services-ads:19.8.0'" on app/build.gradle ?

I added it alogn with "classpath('com.google.gms:google-services:4.2.0')" on build.gradle and still crashing:

The error is *Invalid application ID.

Thank you.

birdofpreyru commented 3 years ago

@huseyin39 I have in app/build.gradle classpath 'com.google.gms:google-services:4.3.4', and it works. I don't think I have com.google.android.gms:play-services-ads explicitly mentioned in gradle files.

Mikenso commented 3 years ago

@huseyin39 Try these classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.google.gms:google-services:4.3.8

The error is *Invalid application ID

Maybe you forgot to add application ID at root folder

CyrusZei commented 3 years ago

Wish I would have that deeper knowledge so that I could help out 😞

huseyin39 commented 3 years ago

Ok guys, it seems working thanks I had indeed an issue with the ID and the version of gms!

mikehardy commented 3 years ago

We still have plans to shift our AdMob implementation from v11.5 out to a standalone and then update it and if you've seen the flurry of activity here recently (just released Installations module, App Distribution module, App Check module!) you'll see I've nearly cleared the backlog that built up while I was solving a nasty App Check issue.

I'm mostly writing to say that if you are still using react-native-firebaes v11.5 to access the AdMob APIs, there was an issue with react-native v0.65 that caused warnings in the log - #5614 but as I went to fix it with #5616 it did not seem like the log warnings were an actual problem. No, they aren't great but if you need the combination of react-native-firebase v11.5.0 and react-native v0.65+ it should be okay to try and then use, if it works for you.

teamseamive commented 3 years ago

@mikehardy when can we expect the Admob shift and what Admob package do you recommend to use as standalone until then?

mikehardy commented 3 years ago

Soon. V11.5 here.

CyrusZei commented 3 years ago

Yeah, I am so sponsoring this!! Awesome job @mikehardy

babyrusa commented 3 years ago

@mikehardy Hello, side question. Since I use @react-native-firebase/admob , I don't see this in rnfirebase documentation but do I have to add com.google.android.gms:play-services-ads in my app/build.gradle file? I do have classpath 'com.google.gms:google-services: in my main build.gradle and the ads worked sometimes but Google kept limiting my ads so I'm not sure if that is because I'm missing com.google.android.gms:play-services-ads in my app/build.gradle file Thank you

mikehardy commented 3 years ago

Google may limit ads for any number of reasons, none of which we can help with unfortunately. If the ads worked at all, the software is working, that's the only knowable thing, as a module maintainer. Sorry I can't help more

babyrusa commented 3 years ago

@mikehardy I know they do this to a lot of people but my question is more on the implementation is if I have to add com.google.android.gms:play-services-ads to my app/build.gradle file if I'm already using @react-native-firebase/admob since it's not in rnfirebase doc but it's in Google Admob SDK doc

mikehardy commented 3 years ago

So you can do . /gradlew :app:dependencies (I think that is the right command) and save the output and see your whole android dependency tree. You can also see what we add to the build.gradle by just looking at it in node_modules right? Investigate, experiment, it's the best way

babyrusa commented 3 years ago

@mikehardy thank you!

dylancom commented 3 years ago

@mikehardy would like to help with upgrading to the latest SDK and getting new features in such as "App Open Ads". Have been relying on this package for quite some time now.

haresh4d commented 3 years ago

That sounds good and could be a good solution @spazfeed do you know if it's already forward-ported to the new AdMob breaking changes? I'm just curious, because we are not forward-ported here, and if that library already is then it is ahead of anything we'd have by splitting the previous code here out

Most probably not. It's still on v19 (Android) & v7 (iOS).

I just create pull request for update Mobile Ads SDK here or you can use it directly from my fork

How can I use your fork? How to install it?

mikehardy commented 3 years ago

Just FYI, we're getting close here, I'm at the "setting up e2e testing" part but the module from previous code here / extracted moved is public now https://github.com/invertase/react-native-google-ads/

next steps are finish a quick e2e bringup to verify functionality, then forward port

No documentation is available yet and it's not on npmjs.com but git references should work

for the migration the general idea is "admob" is now "googleAds" / "AdMob" in types is now "GoogleAds" etc, and the example app shows how to use app.json (not firebase.json) to put in the config keys

It's my current project here, it will be finished before I move to something else

haresh4d commented 3 years ago

Found a great alternative which also supports app open ads.

https://github.com/react-native-admob/admob

bilarslan commented 3 years ago

Just FYI, we're getting close here, I'm at the "setting up e2e testing" part but the module from previous code here / extracted moved is public now https://github.com/invertase/react-native-google-ads/

next steps are finish a quick e2e bringup to verify functionality, then forward port

No documentation is available yet and it's not on npmjs.com but git references should work

for the migration the general idea is "admob" is now "googleAds" / "AdMob" in types is now "GoogleAds" etc, and the example app shows how to use app.json (not firebase.json) to put in the config keys

It's my current project here, it will be finished before I move to something else

Glad to hear that 🎉 Looking forward to first release 👀

haresh4d commented 3 years ago

@mikehardy any update? when https://github.com/invertase/react-native-google-ads/ will be released? Will you also support app open ads?

mikehardy commented 3 years ago

When it's released it will hopefully support the entire API surface area of google ads, and one of the reasons to do a native module wrapper vs pure JS is that if it's possible with the SDK natively (app open ads, for example) it will be possible with the wrapper.

As for progress the last time I had a good chunk of hours to throw at it, I thought it was pretty close :shrug: - it is slow going though, I do understand. Only so many hours in the day and I have a couple hot work projects at the moment

RodolfoGS commented 3 years ago

@mikehardy I've a question regarding to: one of the reasons to do a native module wrapper vs pure JS is...

The previous library (@react-native-firebase/admob) was a "native module wrapper" or a "pure JS"? And the new library will be "native wrapper" or "pure js"? So, the future library will work with the same architecture or will be different?

Thanks

PD: Thank you so much for your hard work!

mikehardy commented 3 years ago

Hi @RodolfoGS - the previous incarnation of admob in @react-native-firebase/admob was a native module wrapper, yes. If you just want JS you can probably do that right now without waiting on anyone :-), but it won't have any native integrations

Pingou commented 2 years ago

@mikehardy Any update? I understand you must be very busy, I'm just wondering if I should wait out a bit more or switch to another package.

dylancom commented 2 years ago

I submitted a few PR's which makes the new repo usable (at least on iOS). For the time being (no npm package yet) it can be added to your projects package.json using: "react-native-google-ads": "github:invertase/react-native-google-ads".

Thanks for getting those in fast @mikehardy!

mikehardy commented 2 years ago

Happy to help! Thanks for helping get out the door. Sorry I did not have the time but I do want to make it clear that the goal is for the package to be alive, and I will look at and merge any PRs that help get it there, as I have with those from @dylancom :-)

mikehardy commented 2 years ago

The new repo is alive and updated to the latest SDKs for AdMob now. It's still moving very quickly and you should test carefully before deploying on it, but it's alive. I'm going to close this, cheers

Ronald3217 commented 2 years ago

This came up as a comment on an unrelated issue and I think I may understand the confusion now - pasting in my comment from there:

Ah - sorry, we've already merged the change where Admob is removed from firebase following it's removal upstream, and the documentation site goes live immediately after merges to main branch.

It is not as great of an experience but for now until we have the admob code re-hosted in a non-firebase repo you can go direct to the usage docs and types / API reference from the v11.5.0 (current stable) tag

https://github.com/invertase/react-native-firebase/tree/v11.5.0/docs/admob https://github.com/invertase/react-native-firebase/blob/v11.5.0/packages/admob/lib/index.d.ts

Normally it's a great thing that the docs site is updated immediately between releases, but in this case it means the documentation for a module that is still live (and will always be, in that version) is gone. I'll have to think on that to see if there's some better way we can keep docs for old versions alive as they are still quite useful

Do you have any idea if it is being updated, or are you planning to update the library in the future? version 11.5.0 is the latest stable version and it works perfectly, but I have doubts if updating the @react-native-firebase/app core to version 14.5.0 makes the application stop working.

Have you used admob v11.5.0 with app v14.5.0? or is this not possible? Sorry for the question, it may sound a bit silly.

mikehardy commented 2 years ago

@Ronald3217 you are in luck! It was peeled out to https://github.com/invertase/react-native-google-mobile-ads and has gone through a few revisions so it is all up to date, it now appears to be stable and we're consolidating the rest of the react-native admob packages in to it (by working with / collaborating with their maintainers)

Go grab that package and move forward with admob, fully separate from Firebase

mikehardy commented 2 years ago

Oh, and as for versioning, never mix versions of react-native-firebase: https://invertase.io/blog/react-native-firebase-versioning

Ronald3217 commented 2 years ago

@Ronald3217 you are in luck! It was peeled out to https://github.com/invertase/react-native-google-mobile-ads and has gone through a few revisions so it is all up to date, it now appears to be stable and we're consolidating the rest of the react-native admob packages in to it (by working with / collaborating with their maintainers)

Go grab that package and move forward with admob, fully separate from Firebase

i am working with @react-native-firebase/app and @react-native-firebase/admob versions 11.5.0 (in released apps) but building one and using firestore and app v14.5.0.

From what I understand you no longer recommend working with the /admob module and instead use react-native-google-mobile-ads (because I've been using the /admob module for a long time and I'm used to its implementation) but it is better implement the new library, I'll have to learn how to use it.

birdofpreyru commented 2 years ago

@Ronald3217 https://github.com/invertase/react-native-google-mobile-ads, as of its v4.2.0 is just react-native-firebase/admob module split into a standalone package, with a bunch of updates / fixes done on the way. You won't have to learn how to use it, just carefully rename library imports and config files in your source code, and maybe do a few other minor changes according to the changelog.

RN Firebase 11.5.0 is almost one year old at this point, still using it you are probably missing some performance / features because of older underlying SDKs, and keep around some bugs fixed since then.

Ronald3217 commented 2 years ago

@Ronald3217 https://github.com/invertase/react-native-google-mobile-ads, as of its v4.2.0 is just react-native-firebase/admob module split into a standalone package, with a bunch of updates / fixes done on the way. You won't have to learn how to use it, just carefully rename library imports and config files in your source code, and maybe do a few other minor changes according to the changelog.

RN Firebase 11.5.0 is almost one year old at this point, still using it you are probably missing some performance / features because of older underlying SDKs, and keep around some bugs fixed since then.

Reading the documentation, I don't see that dependencies need to be implemented in build.gradle app and project. I just have to install it, add app.json and implement it as it says in the documentation?

Thanks in advance for taking the time to respond.

birdofpreyru commented 2 years ago

Yeah, just follow the docs. I believe, there is nothing to do in gradle config for this lib.

Ronald3217 commented 2 years ago

@mikehardy thank you very much, have a nice afternoon.

Ronald3217 commented 2 years ago

Yeah, just follow the docs. I believe, there is nothing to do in gradle config for this lib.

Hello, I have a question for you, have you implemented the new library https://docs.page/invertase/react-native-google-mobile-ads? I've been trying all day but I couldn't.

I have sdk 29, do you think that is the problem. If so, which one should I use?

mikehardy commented 2 years ago

@Ronald3217 if you have a problem with that library, please post in that library. Prior to doing so, please examine the example app (and/or the example construction script - it's scripted: https://github.com/invertase/react-native-google-mobile-ads/blob/main/refresh-example.sh) to make sure you are following best practices and that your local environment is not busted in some way

sdb1228 commented 2 years ago

I know this is closed but @mikehardy and Team over at invertase have done a fantastic job with the new admob package and made migrating from this package super simple (removed firebase admob from package.json cleared dependencies for ios and node_modules reinstalled and added my app id to my app.json) I personally strongly encourage anyone who hasn't yet migrated to do so. Thanks again to @mikehardy and team for putting for the effort to keep this package running.