ANDREW BROGDON: Hey, everybody.
Welcome to another episode of Firecast.
I'm Andrew Brogdon from the mobile ads SDK team,
and on today's episode, I'm going
to show you how to get Firebase and AdMob working together
in an iOS app using CocoaPods.
First we'll link an app with Firebase,
then we'll download the configuration plist file.
Next we'll update CocoaPods to include
just the right dependencies, and then we initialize Firebase.
All right, so step one is linking an app,
and we'll do that in the console.
So I'll meet you in a browser window.
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.
All right, so I've got an app linked
and I've downloaded the plist file
that contains the configuration info for my Firebase project.
Now it's time to get the right SDK components into my app,
so we'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 ad's SDK into it.
So the first thing I need to do, actually, is close Xcode
and create a pod file using pod in it.
There we go.
So I got a pod file, which I'm going to edit using Vim.
Somebody 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 finished.
Now I just need to call Firebase's configure method
when my app launches, so it's back into Xcode.
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 make sure
that all the installed base 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 to the view controller, for example,
import the Firebase framework, and start
playing with AdMob classes.
Here's a [INAUDIBLE] banner view,
and you can see the type resolving right there.
So you know the SDK has properly been imported.
So there we go.
Firebase and AdMob in an app working together,
and it only took a couple minutes.
That's it for this Firecast.
Please leave your questions in the comments below,
or reach out on Twitter and G+ with the hashtag askfirebase.
By the way, if you like seeing videos about mobile ads,
I got a whole other series just about that.
It's got screencasts, feature breakdowns, clones,
moose repellent, hairless cats in sweaters, you name it.
It's called the Mobile Ads Garage,
so if you're interested in mobile ads, check it out.
In the meantime, we'll be dropping a new Firecast
every few days, so don't forget to hit that Subscribe button
and stay up to date.
I'm Andrew Brodgon, and thanks for watching.
[MUSIC PLAYING]