You’ve probably heard about Firebase, but may not know much about how it works and how it fits in with your application. Well, you’ve come to the right place. We’ll go over what Firebase is and how to integrate it with your Android project straight from Android Studio. Buckle up.

Fire-what?

Essentially, Firebase fits into the group of MBaaS, which means, Mobile Backend as a Service. If you are a frontend developer, you will need various services that may require backend capabilities. Think file storage, database, push notifications, analytics, advertisements and more. You can use Firebase to help you in connecting your application with those services. To read more about it, go here.

Follow These Steps

  1. After opening your project in Android Studio, click on the Tools tab and select Firebase
  2. A new window pops up from the right, the Assistant tab, with all the services Firebase offers.
Firebase Assistant

3. Select the service you wish to add to your application by clicking on it. We’ll select Cloud Messaging as an example.

4. Click on the link that shows up, specifically, Set up Firebase Cloud Messaging.

5. The Assistant window will transform into a new menu:

Follow the steps above

Follow the steps outlined in the Assistant, making sure to pay attention to any code that needs adding (and where it needs to be added).

The first step will always require you to connect your application with Firebase. In order to do so, you have to create a project for your application in the Firebase Console.

And the second will guide you to add the specific service you are after. So for our example, FCM stands for Firebase Cloud Messaging.

The following things we need to do are:

  • Create a new class which extends FirebaseMessagingService
  • Override two methods: onNewToken and onMessageReceived
  • Declare the service in your manifest:

6. The last step you will encounter is called Next Steps. Here you will be prompted to go to the Firebase Console. This is in order for you to interact with the service you just added.

You now posses the ability to grant any application you make a powerful backend component that can be up and running in minutes. This will drastically shorten your development time and enable you to focus on what is important for you.

Comments? Questions? Feel free to reach out.

If you liked this article, clap away so that others can enjoy it as well! ?