[MUSIC PLAYING]
JEN PERSON: Dear Firebaser, I have moved on
to work with that bald guy, Colt McCanlis,
to make sweet videos for Google Cloud.
Your mission, if you choose to accept it,
is to serve the Firebase community in my stead,
by answering all of their deepest burning questions
on all things Firebase.
It will be an arduous process.
But with some hard work, I know you will succeed.
Are you ready to take over AskFirebase?
PS-- I left an arugula and ciabatta sandwich
in the micro-kitchen.
Do not eat it.
[MUSIC PLAYING]
SUMIT CHANDEL: Wow.
Most people just do that kind of thing over email.
SPEAKER 1: Jen is leaving?
SUMIT CHANDEL: She's still making videos,
just with Google Cloud now.
SPEAKER 1: What are we going to do?
She was the best at answering Firebaser questions.
SUMIT CHANDEL: I could try hosting an episode or two.
SPEAKER 1: Sumit, you're a fantastic Firebaser.
That thing you did was amazing.
But AskFirebase is no joke.
Questions are constantly coming in
from Twitter, Stack Overflow, all over the place.
You need to know Remote Config
SUMIT CHANDEL: I know remote config.
SPEAKER 1: Firestore.
SUMIT CHANDEL: I know Firestore.
SPEAKER 1: Firebase Cloud Messaging.
SUMIT CHANDEL: Got that one, too.
SPEAKER 1: It's just a lot of information and expertise.
SUMIT CHANDEL: Yeah, I mean, that's kind of my job.
SPEAKER 1: OK, but if you're going to do this,
you need to partner with someone who has a ton of experience.
Someone who people know and love.
Who's organized, focused, laser sharp, and has it all together.
DAVID EAST: Hey, sorry I'm late, but does anyone
know where my laptop is?
SPEAKER 1: Probably left it at your desk.
DAVID EAST: Desk, thank you.
SPEAKER 1: You should pick David.
SUMIT CHANDEL: You mean the guy who doesn't even
know where his laptop is?
DAVID EAST: Where is my desk?
SPEAKER 1: It's just around the corner and to the right.
Yeah, David is great.
DAVID EAST: So it turns out, I don't work in this office.
So I'm just going to.
SUMIT CHANDEL: That guy?
SPEAKER 1: That guy.
SUMIT CHANDEL: Wow.
[MUSIC PLAYING]
Hello, everyone, and welcome to this episode of #AskFirebase.
I'm Sumit Chandel.
And you know what?
I love Popsicles, but I hate lollipops.
DAVID EAST: What?
SUMIT CHANDEL: Yep.
DAVID EAST: I'm David East, and I'm a developer advocate here,
and I like both of those things, because they're delicious.
SUMIT CHANDEL: Gross.
DAVID EAST: Today, we are going to answer your questions
that you've sent in from Twitter, Stack Overflow
and YouTube comments, all tagged with #Ask Firebase.
So why don't we get started?
SUMIT CHANDEL: Question number one from Kevin.
Kevin asks, can you open up APIs for the Firebase console?
Specifically, I'm looking to be able to automate user and role
provisioning for team members.
DAVID EAST: So, Kevin, you actually can do that today.
So Firebase uses a identity access management system
that-- the same one that Google Cloud uses.
And Firebase is built on top of Google Cloud.
So they share these same IAM permissions.
So there is a Google Cloud IAM REST
API that allows you to provision those roles to team members,
and so you can do that auto-magically,
automatically, whatever matically.
It's pretty simple to do.
Just one REST request and we will put a link
in the description below.
So great question, Kevin.
SUMIT AND DAVID: Next question.
DAVID EAST: This next question comes from Frederick
on Twitter.
And Frederick asks, when will dart officially be supported
for writing Cloud Functions?
SUMIT CHANDEL: Well, that's a great question, Frederick.
So at the moment, you can't run dart on functions,
but what you might be interested in
is something called Cloud Run.
If you've used Docker before, you
might be familiar with the concept of containers
that allow you to have a runtime, as well
as your application code and a logic all packaged
into one container that you can run
as a kind of ephemeral package in the cloud
and have accessible to you from anywhere
to have access to that point of functionality.
Well, Cloud Run is kind of similar.
You create a package in whatever language you like,
whether that's dart, Python, Fortran, C++, what have you,
any language, and create this package,
you write the logical code that you want to run in access,
and then have an endpoint that you can use that you can hit
with your application whenever you want to access that piece
of functionality.
So if you've got some dart code, for example,
implementing some really useful stuff that you
want to reuse in your app, you can
use Cloud Run to put that into a package,
put about behind an endpoint and access it
I know I love using it for Fortran.
DAVID EAST: Big Fortran users right here.
SUMIT CHANDEL: Yeah.
DAVID EAST: Great question, Frederick.
SUMIT CHANDEL: You know why I'm so happy?
DAVID EAST: Why?
SUMIT CHANDEL: Because we've got another question.
This next question comes from Angie.
And Angie asks, has anybody done a phone authentication
with Firebase and React hooks before?
DAVID EAST: Great question, Angie.
For those who aren't familiar with React hooks,
they are a new feature of React that has really
taken the world by storm.
SUMIT CHANDEL: I guess you could say everyone's
hooked on React hooks.
[RIM SHOT]
DAVID EAST: With React, you have a component-based architecture
that usually starts with a top app component,
and then you have the sub or these child components.
So something like a form and then a button within the form,
and that we hold state at the topmost component,
and then we pass it down with props.
And with React, while that is a really beautiful and simple
process, it can become difficult at time,
constantly handing things down to the tree
and then making sure that they get updated and passed up
and state being re-rendered.
It's something that a lot of different solutions
have come out in the past to try to simplify this.
And usually, they've been more so third-party solutions.
And hooks is really amazing because it
allows us to do this in any component down the tree.
So I can actually get a hold of state
and reuse it, without having to do all this crazy management
myself.
And it's really awesome.
And since we at Firebase are big React fans,
and we are so excited about it, we
are in the beginning stages of making a brand new JavaScript
library integration between React and Firebase
called React Fire.
And right now, you can actually use a very early alpha version.
And if you're interested in doing that,
put a link in the description.
And what you can do is you can use a Firebase React
hook for getting a user.
So something saying like, use user,
and you can check the current state of the user.
And then as we continue to build this library out,
you will add more methods for things
such as phone authentication.
But that shouldn't stop you though,
Angie, because React hooks are extremely simple to write.
And if you want to see how we're currently doing it,
it's up on GitHub.
So if you just check out the current hooks that we have,
you can see that they're all follow a pretty common pattern.
So you can even do this today before we have
support in it in the library.
Great question, Angie.
SUMIT AND DAVID: Rock, paper, question!
DAVID EAST: This next question comes from Jim.
And Jim asks, I'm currently using FCM and Firebase Cloud
Messaging, and I want to send a notification to my user
after something specific happens.
How do I go about doing that?
SUMIT CHANDEL: Great question, Jim,
and there's a few different takes on how you can kind
handle that situation, When you say something specific happens,
I'd imagine that this could be some kind of event that
happens in the app.
So maybe something if you're logging analytics, for example.
So there's different ways that you
can handle messaging, sending an FCM to users
when something specific happens.
First, let's just talk about Firebase Cloud
Messaging and using analytics.
So let's say after, I don't know, someone purchases
something, that's when you want to send them an FCM.
Well, you could have an analytics event
for that purchase event, and then
create an audience for people who have done those purchases.
And then have a cloud message targeted
for that specific audience that you could send out.
Now, that doesn't necessarily happen in real time or right
after that thing happens.
It's more like, OK, that thing happened,
and now you're going to send an FCM at the time
that you choose, and you'll be able to target that person who
took that action.
So you'll be able to message them and notify them.
Now, if you want to do something more real time or more like,
right after this happens, I want to get their attention,
let them know about something.
So let's say again, a purchase event or that kind of thing.
So in that situation, it could be,
well, OK this person just purchased something,
and now I want to show them some kind of dialogue.
For that, you could use Firebase in app messaging.
So if you're not familiar with it, Firebase in app messaging
provides a few different options for showing notifications
in the app itself.
There's different modals and different types of ways
that you can get the user's attention
and send them a notification.
And those can happen in more close to real time
after specific things occur.
So as soon as they purchase an event, after analytics event
happens, you can say, yeah, when that happens,
I want to show this modal and say, hey,
you purchased some running shoes,
and did you know that there is a deal on tennis
rackets in this same store or something like that.
So that's when you can kind of get their attention
and show them the notification at the same time.
If that's the kind of use case you're
looking to satisfy in getting them,
sending them some kind of notification.
So maybe that could work.
DAVID EAST: Oh, wow, I'm sensing something.
SUMIT CHANDEL: It must be the--
SUMIT AND DAVID: Next question.
DAVID EAST: This next question comes from Kara.
And Kara asks, how do I build a route guard using AngularFire?
SUMIT CHANDEL: Great question, Kara.
For those who aren't familiar, Angular
has the concept of protecting routes or different URL paths
in your app using a route guard.
So it'll have this kind of attribute
when you configure a router to say, for whatever URL,
can this user activate, based on whatever
security rule or access control that you care about.
So for example, if a user is not logged into your app,
you might say they can only activate if they are logged in,
and set up those kind of rules.
So with AngularFire, you can actually
do something similar, and actually very easily,
using the AngularFire AuthGuard.
So this comes with a pre-configured set
of different rules that you might care about,
that might make sense for your app.
So you can configure this really easily
to say, OK, I want users to be able to access the URLs
and activate them if they have these specific conditions
satisfied.
And some of the out of box things
that come with AngularFire AuthGuard, are things like,
is user logged in.
So they can activate if they're logged in.
Are they not anonymous?
That is, they can activate if they're not an anonymous user.
And if they are anonymous, it will just reject them and not
allow them to access that part of your app.
Similarly, for if their email has been verified or not.
So they can only activate if the email's verified and so forth.
There's a lot of really useful different settings
there for securing access to different paths
in your application.
And you can do that with AngularFire and the AngularFire
AuthGuard.
For more details on that, there's a link below.
Just click that, and you can get the full list
of all the different accesses and settings
that you can use in that configuration.
DAVID EAST: Great question, Kara.
SUMIT CHANDEL: Alrighty.
And that is all the time we have on this episode of Ask
Firebase.
Thank you all for some of your questions.
And if you have more questions that you
like us to answer on the next episode,
submit them in the user comments,
on Twitter, on Stack Overflow, and remember
to put that #AskFirebase.
Once again, remember to like and subscribe.
And we'll see you on the next episode.
DAVID EAST: #AskFirebase.
SUMIT CHANDEL: #AskFirebase.