Add Firebase Notifications in Android App

Hello Guys, Today We are going to develop an App with Firebase Cloud Messaging. I’m gonna Explain How To Add Firebase Notifications in Android App.

We don’t write whole code for Messaging. We achieve this with a single line of code that shows Notifications to Our App.

So Let’s Start.

Open Android Studio and Create a Project.

After Creating Project We add this project to firebase console.

Copy the Package name and Open Firebase Console.

Now Add your Package name in Firebase.

Download google-services.json file and copy it to app in the Android Studio.

Now Add Firebase SDK to your App.

dependencies {
        classpath ''
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
dependencies {

    implementation platform('')
    implementation ''
    implementation ''


apply plugin: ''

Also Add Cloud Messaging SDK to your App.

Now We Create an Application Class for our App.

As I said Now we are going to write the single line for Showing Notifications using a method called Topics.

We give a name to our Topic and Use that topic in Firebase to send Notifications.

I have created a topic with the name sample_notification. Users who install my App will automatically subscribe to this topic.



public class MyApplication extends Application {

    public void onCreate() {




<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""

        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />


Now Let’s Test this.

Go to Firebase Console and Open Cloud Messaging.

In Target Section select Topic.

Enter the Topic we created in Android studio.

Now We successfully sent a Notification to our App using Topic.

You Can Integrate this in any of your App.

Check Out Our Android Tutorials Here

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button