DAVID EAST: You asked the questions,
I got the answers on this week of #AskFirebase.
[MUSIC PLAYING]
What's up, everybody.
David here, and I can assure you that this cup of coffee
is not a prop.
That's the stuff.
Welcome to Ask Firebase, where we cover all of your questions
for Android, iOS, and web development.
So we got a lot of questions this week.
So Rodrigo asked on Twitter, "How can I integrate Firebase
with my postgres database?
Thanks."
Thank you, Rodrigo.
How you do this is, I'm assuming that your postgres database
is on a server on your back end somewhere?
You can actually use the server SDKs that the real time
database provides.
And whenever something happens in the Realtime Database,
like there's an update in real time or something like that,
you can synchronize that data with your postgres database
from the Realtime Database.
And if you go to our documentation, which
is in the links below, you can see
how to get started with our server SDKs, which
are for Node.js and Java.
If you are not supported with Node.js or Java,
we have a REST API, which doesn't give you the real time
capabilities, but still will work for any back end.
Question time.
Bradley asks on Twitter, "How expensive are
observers for the client?"
So I'm assuming that you mean Realtime Database observers?
And to think about this question,
we have to think about it in two parts.
So the observer that lives in the client
just thinks about synchronizing data
from the server to the client.
That part is really not all that expensive.
What the second part is is more expensive,
is the data that comes down through that synchronization.
So the data that's downloaded over the network.
And that's what you have to keep track of.
So if you're only synchronizing like 4 kilobytes of data,
10 kilobytes of data at a time, that's pretty cheap.
There's nothing you really have to worry about there.
But when you're starting to synchronize something that's
like a megabyte for every single change,
you're going to rack up quite the bit of the bandwidth bill.
That's the type of thing you need
to look at when you're wondering whether you're
doing something expensive.
Time for another question.
Laxman on Stack Overflow asked, "What
are the differences between the Realtime Database and Firebase
Storage?"
Well, those are two different types
of data when you think about the two of them.
So the Realtime Database is a JSON database,
which means it stores string and object-based data.
If you think about a user profile,
you're going to store the user's name,
their age, their location.
All this basic information about them.
And that is all really just text-based string data.
That works great in the Realtime Database
because we can synchronize that data
from the server to the client, so every time
that user updates their information,
your app automatically gets that update.
So now, let's say the user wants to upload
their photo to their profile.
That data is binary data, which you really
don't want to put into the Realtime Database
because it doesn't fit in string form,
unless you go and do something crazy like Base64 and code it.
And trust me, you don't really want to live that life.
And this is actually where Firebase Storage comes in.
Firebase Storage is exactly the place where
you want to put binary data.
So things like images, and video,
and mp3s, and pretty much really anything you can imagine all
goes there.
You can actually use a download URL
to store in your Realtime Database.
And then that way, you could say Profile URL
is this download link that's stored in Firebase Storage.
So the two work really well in tandem together.
And then also, you have security rules
for your Realtime Database and security rules
in Firebase Storage, so you can still
do the same permissions per user across the two services.
You get a question, and you get a question,
and you get a question.
TJ asked on Twitter, "David, will you
be making a video for retrieving data in realtime
with Firebase in Swift?"
Well, TJ, I may be making this video or my colleague,
Todd Kerpelman, also might be making this video.
But rest assured, you're going to get this video.
Question alert.
Jasan on Stack Overflow asked, "What's
the difference between Firebase Cloud Messaging and Firebase
Notifications?"
So while the names might be kind of similar,
they do two totally different things.
So Firebase Cloud Messaging is the service
that you use to send push notifications to Android
and iOS devices.
You get an FCM token, and then you
use that to send a post request to FCM with your payload.
And that gets delivered to that device.
Now, Firebase Notifications uses Firebase Cloud Messaging.
And it's more so a tool in the Firebase console.
Rather than having to do that post yourself,
this tool will formulate everything
that that post needs to send that device.
Going even further beyond that, you
can use Firebase Analytics to specify which users you want
to send this notification to, so you
can pick a certain audience.
And so, if you only want to send this
to users in the United States or users in Canada,
you can do that with Firebase Notifications.
Questions, questions, questions.
Miqubel on Twitter asks, "What's the best way to handle
multiple app flavors?"
As in, you don't want to register crashes or analytics
on a dev environment, versus a production app.
Well, Miqubel, what you can do is
you can associate a different package or app ID for your app
in the Firebase Console.
So you'll have a development build
and you'll have a production build.
And that way, your crashes and your statistics
are isolated to each one of those package names.
Is there another question?
Why yes, there is.
Tyler asked, "Can I use Firebase with React Native?"
And yes, Tyler.
Yes, you can.
Because as of the 3.1 version of the Firebase SDK,
the authentication and database parts
are compatible with React Native.
And if you want to know how to get started with that,
you can check out our blog post, and I
have a sample GitHub repo that you
can see in the links in the description.
Wow, that's a lot of questions.
Do we have room for another question?
I think so.
Last question.
Abe asked, "Will you update your legacy skateboard
to the new version of Firebase?"
Oh yeah.
So that's it for this week.
Thank you all for sending in your questions.
They were excellent.
And make sure you tune in next week for Wednesday at noon,
and send in your questions on Twitter, Facebook, YouTube,
whatever really, using the hashtag #AskFirebase.
And we'll make sure to get it in next week's show.
If you like this video, make sure to like, subscribe, do
all that great stuff.
And I will see you guys next week.
[MUSIC PLAYING]
We do Stack Overflow too, right?
Yep.
Send them in on Stack Overflow.
I'll trade you an answer for a question.