Reader small image

You're reading from  Firebase Cookbook

Product typeBook
Published inNov 2017
PublisherPackt
ISBN-139781788296335
Edition1st Edition
Right arrow
Author (1)
Houssem Yahiaoui
Houssem Yahiaoui
author image
Houssem Yahiaoui

Houssem Yahiaoui is a Telerik Developer Expert, Google Developer Group Lead, Meetup organizer, Conference Speaker, and Technical blogger among a few things. He has been a developer since the age of 14 and Firebase lover since day one. He's also a passionate JavaScript developer and strongly believes that JavaScript should fix the World's hanger problem.
Read more about Houssem Yahiaoui

Right arrow

Extend Firebase with Cloud Functions

In this chapter, we're going to cover the following recipes:

  • Getting started with Cloud Functions
  • Implementing data manipulation
  • Implementing data-change monitoring
  • Welcoming users upon account creation
  • Implementing account email confirmation
  • Sending re-engagement emails to inactive Firebase users

Introduction 

Knowing about Firebase's static capabilities, going the extra mile with it can be difficult, if not impossible, sometimes. However, the Firebase team this year has introduced something that, in my opinion, will change the rules of the game. I'm speaking technically about Firebase Cloud Functions. Cloud Functions is the perfect solution for extending most of the present capabilities of Firebase, from the database to allowing awesome re-engagement for your users. Using Cloud Functions will transform your application from being just backend-less to serverless, with zero maintenance. This means that you are going to perform some magic in order to make sure that your function is behaving with one to endless users. At the same time, you can ensure that they are secure and that their privacy is never jeopardized.

The functions we're going to write will...

Getting started with Cloud Functions 

In this recipe, we're going to see, step by step, how we can integrate Cloud Functions with our project. We can use this recipe whenever we want to integrate Cloud Functions with a project, so let's get cloudy!

Getting ready

Everything starts from the Firebase CLI, an awesome utility for handling all your Firebase needs.

For a more precise idea of how to download and install the Firebase Admin SDK onto a development machine, please refer to the Chapter 7, Firebase Admin SDK.

How to do it...

After we've successfully...

Implementing data manipulation

The Firebase database is bundled with lots of events, and for our Cloud Functions to function properly we're going to exploit a set of these functions that will make our lives much simpler.

As a use case, we're going to see how we can integrate Firebase Cloud Functions within an Online store. The function job here is to listen to any new-made unfinished purchase and set its status to pending state.

So, let's get to it!

Getting ready

Before you start adding your function's implementation, please make sure that your project is ready for Cloud Functions. For double check, please look at the preceding recipe for help--Getting started with Cloud Functions.

...

Implementing data-change monitoring

Have you ever wondered what would it be like if you could add extra behavior, or even receive a notification, whenever there's a data manipulation in your database? I bet that would be great to have a feature, and you would be amazed to know that Firebase Cloud Functions has got you covered!

In this recipe, we're going to integrate the monitoring of changes made to data using Firebase Cloud Functions.

Getting ready

Before you start adding your function's implementation, please make sure that your project is ready for Cloud Functions. To double check, please refer to the Getting started with Cloud Functions recipe for assistance.

...

Welcoming users upon account creation

Welcoming our users when they create their account is something we would have definitely wanted to do before. But, due to lack of support, it was not possible. Now that we have this facility provided by Firebase, it allows us to have an extra custom backend to welcome users to account creation. In this recipe, we're going to see how we can make that happen!

Getting ready

Before you start adding your function's implementation, please make sure that your project is ready for Cloud Functions.

How to do it...

  1. The new version...

Implementing account email confirmation

The email confirmation process is one of the most widely spread functionalities over forms and event management applications. Firebase truly shines as it uses such an application, and now with Cloud Functions, we can make the process faster and free of backend code. So, let's see how we can make this happen.

Getting ready

Before you start adding your function's implementation, you will need to complete the extra step and configure your project with Cloud Functions. To do so, just check the Getting started with Cloud Functions recipe.

How to do it...

...

Sending re-engagement emails to inactive Firebase users

What if your users go a bit inactive, and you want to notify them about the best new thing happening within your application? In this recipe, we're going to see how we can do just that!

Getting ready

Before you start adding your function's implementation, please make sure that your project is ready for Cloud Functions.

Next, you will need to install some dependencies locally. To do this, open your function project and create a package.json file and copy and paste the following code snippet:

      "dependencies": {
"es6-promise-pool": "^2.4.4",
"firebase-admin": "^4.1.1",
"firebase...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Firebase Cookbook
Published in: Nov 2017Publisher: PacktISBN-13: 9781788296335
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Houssem Yahiaoui

Houssem Yahiaoui is a Telerik Developer Expert, Google Developer Group Lead, Meetup organizer, Conference Speaker, and Technical blogger among a few things. He has been a developer since the age of 14 and Firebase lover since day one. He's also a passionate JavaScript developer and strongly believes that JavaScript should fix the World's hanger problem.
Read more about Houssem Yahiaoui