Firebase’s goal is to help developers build better apps and grow them into successful businesses. By taking care of your app back-end or infrastructure, Firebase lets you focus on solving problems for your users. One of the new exciting features announced at the Google Cloud Next ’17 Conference this March for Firebase was Cloud Functions. In this tutorial, you’ll learn about this new feature by building a simple Android app with it.
What Are Cloud Functions for Firebase?
For now, Cloud Functions support the following triggers that you can listen to and respond to:
- Realtime Database Triggers: fire a function when a write event occurs on a path in a database.
- Authentication Triggers: fire a function when a new user is created or when a user is deleted.
- Analytics Triggers: fire a function when a new conversion event is logged.
- Cloud Storage Triggers: a function can be fired when there is any change in a bucket such as a file or folder upload, update, or delete.
- Cloud Pub/Sub Triggers: fire a function when a new message is received in a Google Cloud Pub/Sub topic.
- HTTPS Triggers: fire when a request is made to an endpoint.
So Why Use Cloud Functions?
So now you have seen the range of capabilities that Cloud Functions can offer. But why use them?
Running and setting up a back end and servers can be a real pain—you have to handle issues such as scalability and writing code in server-side languages—but with Cloud Functions, this complexity is reduced. Also, computationally intensive tasks can be performed in the cloud instead of on the client device (such as image resizing for upload or writing to multiple paths of your database). Your code will also be more secure in the cloud than on the client device, so you can securely store data such as secret keys on your server.
In this tutorial, you’ll learn how to use the Realtime Database Triggers that will fire when a database write event occurs. Then, we’ll see how to use the Firebase Cloud Messaging service to send a notification to devices that subscribed to a topic. We’ll create a simple app called Tutsplus Alerts, which will send a notification to subscribers of the “android” topic whenever a new article is available.
Continue to read the full article on Tuts+.