Home » Push Notification » How to set up an android app in firebase

How to set up an android app in firebase

In this article let me explain how to set up the android app in Firebase Console. Please go through the step-by-step process.

  1. Create the project in Firebase Console
  2. Add the android app to the project.

Create the project in Firebase Console

1. Log in to Firebase Console then click the option create a project. On the screen, you can put the project name to continue. We can add n number of android apps in a single project itself.

Firebase

2. In the second step you can enable Google Analytics for the project. Google analytics provides much functionality like A/B Testing, Crash-free Users, User segmentation and targeting across Firebase products, Free unlimited reporting, and predicting user behavior like that. I can explain this in a different post. So leave it as of now then click continue.

Firebase

3. If you enabled Google Analytics in the previous step then you have to select the Google Analytics account name. You can put your project name and continue or select an already existing project name and continue. Now you have created the project in the Firebase console successfully.

Firebase

Once the project is created successfully then you can start to add the apps to it. You can add Android, IOS, and Web Apps

Add the Android App into the project.

Please follow the below step-by-step process for adding an android app.

1. Register App.

You can see the icons inside like android, ios, and web apps. Please choose the android icon to add the app. In the below screen you have to enter the app details and continue.

Firebase

Enter the package name and app nickname then click the register app button. The package name should be the same as the android app package name.

2. Download the Config file

Once registration is successful then you have to download the config file (google-services.json) which you want to configure at the android application. Keep the downloaded file in the root directory of Android Studio. Then Google services plug-in loads the added file (google-services.json). You have to click the sync button to sync the app. Before that, you have to do some changes to the build.gradle at the project level. The below screen shows how you modify the build.gradle file.

Firebase
Firebase

3. Once the changes are completed in build and app-level Gradle files then click next. Then run your app to verify the installation. For this, you may need to uninstall and reinstall your app.

Now you successfully added the android app to your project. If you want to set up the java SDK on the server-side please through this link (Set up firebase Java SDK).

Test Push Notification with Firebase Console

Now, let's start to test the push notification with configured android device. We can test push notifications with Firebase Cloud Messaging. Log in to your email and go to Firebase Console in a web browser.

In the Firebase console select the project you configured then you can see the Cloud Messaging option in the left side panel. This is the place we can test push notifications with our android device.

Click the new notification button in the notification section then you can see the push notification screen. On that screen, you can fill in the notification details and push that to devices.

There are five sections available which are notification, target, scheduling, conversion events, and additional options.

  1. Notification

In the notification section, you have to fill in the notification title, text, image and etc. You can see the demo instantly on the right side that how it will be displayed on a mobile screen.

2. Target

In the target section, you have to select the app to which you are going to send a push notification. Once you selected then all the users registered in-app will get a notification.

3. Scheduling

In the scheduling section, you have to choose the time to push. By default, it sets as Now. But you can change your scheduled date. For testing please set this as Now.

Firebase-Cloud-Messaging
Firebase-Cloud-Messaging

Yah! Now everything is fine. Click the review button and then click push. Now your device gets a notification successfully.

Leave a Reply

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