How to add Cloud messaging to your Android app

Firebase Cloud Messaging

Firebase Cloud Messaging is a tool that helps you send notification messages or data messages to your client app whether it’s a single device, a group of devices, or devices subscribed to topics. The best part is that this service can be used at no cost.

Requirements

  • Android Studio
  • Google Account

How to add cloud messaging to your Android app

Step 1. Open your project in Android Studio, click on ToolsFirebase. Now, a list of Firebase tools will appear on the left, Scroll down and select Cloud Messaging, and then click on Set up Firebase Cloud Messaging.

Step 2. Connect your app to Firebase

After clicking on Connect to Firebase, your browser will open. Then, select your google account.

Step 3. Create new Project in Firebase

  • Click on Create a project

  • Name your Project and click Next

  • Click on Create Project

Now, it will take a few seconds to build your Project.

Once the project is built successfully, Connect Firebase with your Android Studio Project.

After connecting your project go back to Android Studio

Step 4. Add FCM to Your app

Now, click on Accept Changes and build your Project.

Step 5. Run your App on AVD or any Physical Device


To send a notification to your app, go to Firebase console → Cloud Messaging → Input Your Notification content → select your app as Target → Schedule your notification → click Publish.