TODD KERPELMAN: That cam? [SPUTTERING]
Most pleasant mother pheasant-plucker to ever pluck
a mother pheasant.
DAVID EAST: Simon simply said that the Firebase database
is schema-less.
That's my tongue-twister.
SPEAKER 1: AskFirebase, W09, take one.
DAVID EAST: What's up, everybody?
Welcome back to another episode of #AskFirebase.
And today is a super-special episode
because we have my coworker, my colleague, my friend,
dare I say my muse, Todd Kerpelman on the show.
TODD KERPELMAN: Aw.
DAVID EAST: And Todd is a Developer Advocate
here at Firebase with a specialty for iOS.
Fun fact about Todd is that his favorite color is red,
and the make of his first car is Nissan,
and his favorite childhood friend is named Adam.
His mother's maiden name is Davis,
and the first four of his social security is 9, 1, 4, 2.
TODD KERPELMAN: Uh, David, are you stealing my identity?
DAVID EAST: Well, apparently I already have.
TODD KERPELMAN: Oh.
DAVID EAST: We have a great episode for you today.
Todd is an amazing iOS developer so we
have lots of questions focused on iOS today.
So how about we get started?
TODD KERPELMAN: Sounds good.
DAVID AND TODD TOGETHER: Question time.
[GORILLA SOUNDS]
DAVID EAST: You're a much better gorilla than me.
TODD KERPELMAN: Well.
So this is from [? vineath ?] on Twitter
who asks, hey AskFirebase, hashtag, are there
any videos coming up on crash reporting on iOS?
And the answer is, yes, eventually.
I've got a few videos that I need to do on analytics first.
We're going to have a little series on that, and then
maybe one or two on dynamic links that I'd like to address,
some advanced topics there.
But then, yes.
I do want to at least cover the basics of screencasts
on all the features that Firebase has to offer,
one of those being crash reporting.
It's generally easy to set up.
Testing it is a little weird because you
have to kind of make sure that Xcode doesn't sort of grab
the crash before crash reporting does.
DAVID EAST: I heard that you just published a video
on Firebase storage in iOS.
TODD KERPELMAN: That might be true,
but only subscribers would get to find out,
so maybe you should subscribe, somewhere down here.
DAVID EAST: It's down there.
TODD KERPELMAN: I betcha there's a button.
Down here?
DAVID EAST: Right here.
TODD KERPELMAN: Look underneath here.
There's probably a button.
DAVID EAST: It's right there.
TODD KERPELMAN: Oh, there it is.
What's that out on the horizon?
It looks like another question.
This one is also from [? vineath ?] on Twitter
who has a two-parter here.
One, how can we send interactive push notifications
to iOS devices?
And two, how can we send push notifications to all devices
from my terminal in Mac?
DAVID EAST: What is an interactive push notification,
Todd?
TODD KERPELMAN: Well, I don't quite know what he means,
but my guess is it probably has to do with those categories
that you get in notifications on iOS.
So you can specify a category that any notification belongs
to.
You can then add actions to that category and that gives you,
like, those nice two or three buttons that
get associated with a notification when
you receive them on iOS.
So the answer is that you can do that,
but when you are sending this notification to the Firebase
Cloud Messaging service you need to add the Click Action
key instead of Category.
So if you were sending this to APNS,
you would say, Category, my special category.
Within Firebase Cloud Messaging you
need to say, click underscore action,
and then add your category name.
And that will make those notifications interactive
on iOS.
Unless of course he's talking about some
of the extra-special fancy stuff that Apple has added
into notifications on iOS 10.
For that, that requires a fairly new user notification
framework, and that's something that we
will be supporting soon, if not by the time this video is out.
So keep a look out for that.
For the second part, how can we send notifications
to all devices from my terminal in Mac?
So Firebase Notifications has this really nice feature
where you can say, hey, let's send this message to everybody
who's using this app.
You can't actually do that with a cURL command or something
like that from the terminal.
What you can do as a workaround, and I
think what a lot of developers do,
is they simply have every instance of their client
subscribe to, like, an all-users topic
within Firebase Cloud Messaging.
And then you can send a notification
to everybody within that topic from your desktop
or from your server or from a little cURL call.
And that's how you'd basically send these notifications
to all of your clients.
Thank you for that two-parter.
Both very good questions.
Let's see what else we got.
Incoming question!
[BOTH SCREAMING]
DAVID EAST: This next question comes from Lucien on Twitter.
And Lucian asks, I saw a code lab
on how to build real-time chat for the web.
Can we do the same for Android and iOS?
And yes, Lucien, you can.
If you go to the Codelabs website,
there's actually two code labs, one for Firebase iOS code
lab in Swift, and then another one for Firebase Android code
lab that will get you up and running
building your magical chat app in no time.
So if you want to check that out,
link is in the description.
Great question, Lucien.
TODD KERPELMAN: We got a question coming in.
[BOTH SPUTTERING]
This is from David West who asks--
DAVID EAST: Wait, what?
TODD KERPELMAN: Oh, wow.
He's really David West on Twitter.
DAVID EAST: His name is actually David West.
TODD KERPELMAN: Wow.
Maybe he's your evil twin.
DAVID EAST: Yeah.
TODD KERPELMAN: Wait, what if he's the nice one.
That would make you--
DAVID EAST: What?
TODD KERPELMAN: So David asks, I love using Firebase on iOS.
Oh, thank you.
What is the best way to sync data to and from WatchOS?
DAVID EAST: Well, from what I understand
is that WatchOS doesn't support all of the libraries
that you can get on your iPhone.
And mainly for Firebase the problem there is CF Network.
That's how we do the socket connection.
So what do we do, Todd?
TODD KERPELMAN: So, yeah.
My understanding is, you cannot connect to Firebase directly
from your watch.
You would probably have to use your phone
to communicate back and forth to Firebase
and then communicate any relevant changes back
up to the watch from there.
And for that I think you'd probably
use your standard, like, Watch Connectivity Library
with the Update Application Context
call to do most of that.
But I would like to add a caveat that I haven't actually
made any WatchOS applications, so I may or may not
know what I'm talking about because I don't have an Apple
Watch.
But if anyone out there would like
to send me their Apple Watch, I-- that
was not an Apple Watch.
But if you would like to send me an Apple Watch
I promise that I will wear it during my next episode.
That is a great question, David West.
DAVID EAST: And I'm watching you.
Uh, what's going on in there?
TODD KERPELMAN: I got another question.
It's in 3D.
DAVID EAST: I've never actually geeked like this before.
OK.
Todd, you-- what you do to me, Todd.
TODD KERPELMAN: I do this.
DAVID EAST: It's good though.
So this next question comes from Anton on YouTube.
And Anton asks, can a dynamic link survive a sign-up or login
process?
So Todd, what do those words actually mean?
TODD KERPELMAN: So the deal with Firebase Dynamic Links,
what makes them so special, is that they can survive the app
installation process.
Meaning that, if a user clicks on a dynamic link,
goes to install your app, and then opens
your app for the first time, that app
can retrieve the original context of the deep link
that the user clicked on to install
your app in the first place.
And then you can use that information
to provide them with sort of a customized first-time
experience and so on.
I believe what Anton is asking is, well,
what if you need your user to, like, sign in first
or go through some type of setup process?
The answer is, yes, a dynamic link can survive that, too,
but it's up to you, the app developer,
to actually remember that.
So you will get a dynamic link context
when the user first opens your app,
but if you want your user to go through the whole process
of signing in before they can use your app you've
got to remember that somewhere.
You know, store it in, like, your user settings or something
so you can grab it later.
Then after your user is finished signing in, setting up
an account, doing whatever it is you need them to do,
then go ahead and grab that original link
and then perform whatever first-time experience you
want to present to that user.
All right.
Thank you very much, Anton.
Great question.
DAVID EAST: Thanks for clarifying.
TODD KERPELMAN: That's what I'm here for.
DAVID EAST: So I was--
TODD KERPELMAN: Whoa, whoa, stop.
Question time.
This question comes from Nickin on YouTube
who asks, how can I get real-time active users
of my app through Firebase?
Is it possible?
Well now, since this question was asked in response
to our Firebase Analytics video I'm
kind of assuming the question is,
how can I do this through Firebase Analytics?
Can I open up my analytics page and see how many people
are using my app right now.
And the answer basically is, no, you can't quite do this.
Generally speaking, if you're looking
at timing for Firebase Analytics,
your device will send down data from the device
to Firebase Analytics about once an hour or on iOS
when your app goes into the background.
Now, once Firebase Analytics receives that data,
it can immediately export that data to BigQuery
if you've linked up Firebase Analytics and BigQuery,
and you can see your data in there
nearly as soon as Firebase Analytics receives it.
And then on the Firebase Analytics side, every couple
hours it will process the data that it has and munches it up
and spits it out to you in sort of a nicely-formatted way.
But if you're actually looking to see how many people right
now are using my app, you can't really do that
through Firebase Analytics.
So if only there were some other way.
Well, thank you for asking the question--
DAVID EAST: All right.
Todd.
TODD KERPELMAN: What?
DAVID EAST: You can actually use the real-time database
to see which users are active in your app.
TODD KERPELMAN: We have a real-time database?
DAVID EAST: Yeah.
Sure.
TODD KERPELMAN: That's awesome.
DAVID EAST: It's real-time.
And it's a database.
So if you use the real-time database,
it has a present system.
So the real-time database uses a socket connection.
So that is a persistent connection
from the device up to the real-time database.
So when someone joins it knows that, and when someone leaves
it knows that as well.
So you can use the [? on ?] [? disconnect ?] methods
to know.
When someone signs up you just do your business,
and then when they do [? on ?] [? disconnect ?] you can just
remove them from the queue.
So it would have a list of active users,
and when they leave just pluck them right off.
TODD KERPELMAN: Hm.
Well, that works too, I guess.
DAVID EAST: Yeah.
TODD KERPELMAN: All right.
DAVID EAST: Firebase.
It works.
TODD KERPELMAN: Firebase.
That's cool.
All right.
Well, thank you very much, Nickin, for your question.
Good question.
Excellent question, I would say.
DAVID EAST: Was it a good question?
TODD KERPELMAN: I think it was a good question.
DAVID EAST: It was a good question.
TODD KERPELMAN: Yeah.
DAVID EAST: Thank you all so much for stopping by the show.
And thank you, Todd, for stopping by as well.
TODD KERPELMAN: Well, thanks for having me.
This was fun.
DAVID EAST: Oh yeah.
Always a pleasure, Todd.
And if you want your question answered on next week's
episode, make sure to send it on YouTube, Twitter, Stack
Overflow, and like always use the #AskFirebase.
And that's all.
Thank you all so much, and we will see you next time.
TODD KERPELMAN: All right.
I gotta go change all my passwords now.
DAVID EAST: Oh no, I already did that for you.
TODD KERPELMAN: Oh.
All right.
Oh, that was terrible.
There we go.
Yeah.
That's how we fight in Firebase land.
DAVID EAST: That's how we do it.
TODD KERPELMAN: Aggressive patty-caking.
Patty cake.
That'd be awesome.