Firebase: Push Notification

Firebase is a mobile and web application development platform that can bring to ours application different services and functionality, one of them is “Cloud Messaging”, providing us tools to send information to our user when ever we want, so that we can, for example, have that communication with our users when they are not using our app with push notifications.

So, now that we know what Firebase is, let’s learn how we can include it in our Android applications.

How can you start to use Firebase?

In the first place before we can use the Authentication service we need to include Firebase in our apps. To do that, follow these steps:

– First we need to get to the Firebase console and once we are there we click on “Add project”.

– Fill the following form to create your project.

– After that it will redirect you to your project’s overview page where we will specify the type of application we are creating. Because we are doing and Android you can select that option.

– After we click on it, it will give some steps to register our app. In the first will just need to some information about our application.

-For the next step, it will give us a JSON file which you can download and add to your “app” folder in your Android application.

-The next thing we have to do is add some lines to our build.gradle files:

. In your project “build.gradle” file, add this line:

 	 dependencies {
    		classpath ''

. In your app “build.gradle” file, add these lines:

  	dependencies {
           implementation ''
	// Add this at the bottom of the file
	apply plugin: ''

After we add those lines to our Android project we will have FireBase setup and ready to be used in our app (The last step on the page is to verify that the app is connected to the Firebase console).

Implement Firebase Cloud Messaging

– To start to use Firebase Cloud Messaging you need to make sure you the “firebasecore” dependency implemented and add the next one in the app “build.gradle” file:

implementation ''

Adding this dependency your app will be able to send notifications when the users is not being used. In the case that you want to also show the notification when the app is being used, you will need to create a local notification with the information of the push notification using the object “RemoteMessage” and use the function of ” getNotification().getBody()” to get the text message.

But this is all for the basics of Cloud Messaging givin us the opportunity to use push notification in our app. If you want to know more things you can do, you can do it visiting this page.