[MUSIC PLAYING]
ANDREW BROGDON: Hey, everybody.
Welcome back to the Mobile Ads Garage.
Today is all about Firebase, Google's mobile platform that
helps you quickly develop high quality apps,
grow your user base, and earn money.
If you watch the keynote from I/O 16,
you heard that Firebase now offers
a whole bunch of new services and that AdMob is one of them.
So in this episode, with the help of Gary the Graphics Guy,
we're going to cover how Firebase and AdMob work
together, what the benefits are, and then we'll
have screencasts showing how to import the Mobile Ads SDK along
with the Firebase SDK.
But first, let me step into my app
so I can welcome our first ever guest star,
noted Firebase expert and star of the Firecast series, David
East.
[FANFARE]
DAVID EAST: What's up, everybody?
ANDREW BROGDON: What?
We have company.
Now then, David, maybe you could tell our viewers
about what Firebase is.
DAVID EAST: Sure.
Yeah.
Firebase is a unified app platform for Android, iOS,
and web development with tools to help develop faster,
improve app quality, acquire and engage users, and monetize
apps.
ANDREW BROGDON: So what kind of tools are we talking about?
DAVID EAST: Man, there's a bunch,
like my favorite, the real-time database, notifications,
crash reporting, analytics, and, of course, probably
your favorite, AdMob.
ANDREW BROGDON: So part of the platform is AdMob?
DAVID EAST: Yeah.
Firebase is designed to help developers
at every stage of the lifecycle.
So you can actually get a lot out of the Firebase tools
at no charge like analytics, remote config, push
notifications, and then AdMob will actually go and pay you.
No.
It is true.
I'm actually not that good of a salesman.
ANDREW BROGDON: Firebase and AdMob are friends, Gary.
OK.
So that's why someone would want to use Firebase.
But what about how?
If an AdMob publisher wants to get on board with Firebase,
how do they do that?
DAVID EAST: Well, they can actually
link AdMob apps to Firebase projects
right from the AdMob website.
And then, mainly, it's a matter of getting the config file
and importing the SDKs.
ANDREW BROGDON: Cool.
So around here, I like to list the steps
before we do a screencast.
So let's break it down for Android.
So to get an Android app up and running
with AdMob and Firebase, you just
need to link the app with a Firebase project,
download the Firebase config file
and include it, configure the Google services Gradle plugin,
and then add individual services.
DAVID EAST: Yeah.
I can't see anything.
ANDREW BROGDON: Gary, unblock him.
David's a nice guy.
Haven't you seen Firecast?
What's the problem?
Is that what this is about?
It's still you and me buddy.
AdMob's not going anywhere.
You don't have to use Firebase with it if you don't want to.
The API isn't changing.
The SDK still works the way it always has.
If publishers don't have to make big changes, neither do we.
Absolutely.
We can still catch a ball game together.
DAVID EAST: Yeah.
I have season tickets.
See?
It's a win-win.
ANDREW BROGDON: Now that that's settled,
let's get to our screencast and take a look
at how to use Firebase and AdMob together in an Android app.
So here are the four steps for Android.
We're going to begin with the first,
linking an AdMob app to a Firebase project.
I'll include a guide at the end of this video
with more info on how this linking works,
but for now, one of the easiest ways to get started
is just to go to the Analytics tab in AdMob console
and click this nice Get Started With Firebase button.
When I click that, I get to a list of my AdMob apps.
And I can click the Link to Firebase button
to link one to Firebase.
That gets me a prompt for my app's package
name, which is needed for the configuration stuff
to work later.
And depending on whether you've already
created a Firebase project or not,
you may have some choices on the next screen.
This is what you get if you've never created a Firebase base
project before.
Clicking continue will take you to the next screen--
one that looks like this telling you
that you now have a linked app.
And so that's step one.
Step two is to download the google-services.json config
file, which is really easy because the screen I just
showed you has a link to it right there.
Just click that link.
And you'll be sent to the Firebase console.
And the download will start automatically.
Once it's downloaded, I can go into an Android Studio project
and drag it right into the source tree, like that.
It goes in the root folder of the app source.
And it'll be used later by the Google services plug-in.
Cool.
So step one and two down.
On to step three, configuring the Gradle plugin.
So here, I'm back in Android Studio.
And I'm looking at the project level build.gradle file.
That's the one that applies not just to the app,
but everything in the project's source tree.
And so I'm just going to add a little class path here
for the Google services plug-in, which is new.
And we're doing a Gradle sync.
There we go.
With that done, I can head into the apps build.gradle
and add a line at the bottom to apply that plugin.
There we go.
This plugin uses the google-services.json file
to inject configuration data into the app when it builds.
And it also does some other Firebase-y
set up kind of stuff.
So that's the plugin.
Now, it's time for the last step,
adding individual services.
I can do that the same way I always have,
through Gradle dependencies.
So for AdMob with Firebase, the Gradle artifact
is called firebase-ads.
There we go.
There are, by the way, a ton of these artifacts available.
Here's a list of the services along with Gradle dependencies
that go with them, which you can find in the Firebase Android
Setup Guide.
And you see there's a bunch in here-- real time
database, authentication, everything you might want.
So that's all four steps finished,
which means I can come back into my activity file now
and start messing around with AdMob classes, like AdView.
And you can see, the type is resolving.
So you know the SDK has been properly imported.
So what did you think?
DAVID EAST: Looks all right to me.
ANDREW BROGDON: Excellent.
So up next is iOS.
Let's take a look at the steps there.
Gary, hello.
And we're back to the pudgy redhead jokes.
All is right with the world.
David, do you mind?
DAVID EAST: Nope.
To get an iOS up and running with AdMob and Firebase,
first, you link the app to a Firebase project.
Then you download a configuration plist file.
Next, you update your pod file to reference the Firebase pods.
And then initialize Firebase in your app.
Thanks.
I'll let you do the screencast though.
ANDREW BROGDON: OK.
So here are the four steps for iOS.
And we're going to begin with the first,
linking an AdMob app to a Firebase project.
There's a bunch of ways to get started on this.
And I'll include a guide at the end of this video.
But for now, I'm just going to go to the Analytics tab
in the AdMob console, where the front-end team has
this nice, Get Started With Firebase button.
When I click that, I get a list of my AdMob apps.
And I can click Link to Firebase, right here,
to link my app.
That gets me a prompt for my app's bundle
ID, which is needed for the configuration stuff
to work later.
And depending on whether you've already
created a Firebase project or not,
you may have some choices on the next screen.
Here, you can either link the app
to one of your existing Firebase projects
or create a brand new one.
Either way, once you're done with this screen,
you get one that looks like this telling you the app is linked.
So that's step one.
Step two is to download the plist file that
contains your Firebase configuration
information, which is crazy easy because the screen
I just showed you has a link right to it.
Right there.
That'll take you to the Firebase console
and start the download automatically.
Cool.
So that's steps one and two.
Let's take a look at step three, updating
the project's CocoaPods.
So I'll head into Xcode.
And here's my very basic iOS app.
And I'm going to use CocoaPods to get the Firebase SDK
and the Mobile Ads SDK into it.
So the first thing I need to do, actually, is close Xcode
and create a pod file using pod init.
There we go.
So I got a pod file, which I'm going to edit using Vim
so everybody out there thinks I'm smart.
Cool.
Inside the pod file, I just need to add two dependencies
to my target.
First is the Firebase pod, which gives me
access to basic Firebase stuff, like the Firebase app
class, which you'll see in a second, plus Firebase
Analytics.
And then a second pod for AdMob.
There are, by the way, a ton of these pods.
Here's a list of the available Firebase services
and the pods that go with them, which
you can find in the setup guide I'll
actually link you to later.
But as you can see, there's a whole bunch.
Cool.
So now, I do a pod install to get all my new dependencies.
There we go.
And now, I'll open the workspace file
that CocoaPods made for me to get back into Xcode.
So that's steps one through three.
The last step is to initialize Firebase.
To start, I'm going to grab that plist file
that we downloaded earlier.
And I'm going to drag it into the root of my source tree.
Firebase uses this config file to store a bunch of keys and ID
kind of things.
That's what the file's for.
There we go.
Next, in my AppDelegate I'm going
to import the Firebase framework provided to me by the pods
and then call the configure method in the Firebase app
class.
There we go.
That configures my app at launch and makes
sure that all the installed Firebase
components are ready to go.
So that's it.
I'm done with all four steps.
And AdMob with Firebase is ready to go.
That means I can come into the view controller, for example,
import the Firebase framework, and start
playing with AdMob classes.
Here's a GADBannerView.
And you can see the type resolving, right there.
So you know the SDK has properly been imported.
One thing I do want to note is that the dedicated
Google Mobile Ads SDK, CocoaPod, the one that everybody's
been used to using up until now--
that has not been deprecated.
So if you're not interested in using Firebase,
but you do still want to use AdMob,
that's an option for you.
It's not going away.
Also, if you don't want to use CocoaPods,
you can also download these frameworks directly
from the Firebase developer site, firebase.google.com.
So that's iOS.
I'm going to put up some resource links for you guys.
But first, thanks to David for stopping by.
DAVID EAST: My pleasure.
By the way, if you want to learn more about Firebase,
you can check out Firecast, where we cover everything
you need to know about Firebase for Android, iOS, and web
with step-by-step screencast.
ANDREW BROGDON: Sounds great.
Thanks.
DAVID EAST: Thanks for having me.
So that's one good resource.
You might also be interested in the AdMob quick starts
for Android and iOS, which we've updated to include Firebase.
We've also updated our AdMob samples
to show the use of Firebase.
So you can check those out on Github.
And we've got a help center article
that covers how to link your AdMob
apps with Firebase projects.
And the Firebase support page has a number of good options
if you have questions.
As always, if you have technical questions about the Mobile Ads
SDK, stop by our support forum.
And Gary and I will see you next time.
[MUSIC PLAYING]