Home / Tutorials / How to add push notification in android application from android studio – Android developer (part – 1 Connect with firebase )

How to add push notification in android application from android studio – Android developer (part – 1 Connect with firebase )

Assalamualaikum, Here is Rana to tech you how to add push notification in android app step by step.

First of all, lets discuss about push notification.

What is push notification in android application?

=>Push notification is a notification system which will give access to application owner top sent notification any time to the user. So it’s mainly a manual notification which can manage app developer manually.

Push notification is necessary for promoting special updates, notify user about present stat and in many other ways..

Now how can you add push notification in your own android application.. Its simple and easy to use.. Here is  important things which will need to add push notification to an android project.

  1. Firebase
  2. Own server (for sending custom notification and opening specific ativity )\

Step 1:

So lets begin with the tutorial..In the end I will provide you an sample application project which will clear your concept.

 

Step 1: Create firebase account

Visit https://console.firebase.google.com then create a firebase account using google account. Go to console and create a new project ..

create-project-in-fire-base-android-push-notiofication

 

Step 2:

if you are using android studio 2.2+ version then you can add fire base from your android studio.. Other wise you have to follow manual implement method for andriod studio version less then 2.2

For Android Studio version greater or equal to  2.2:

just go to Tools=> firebase and select the “notification” option from the right popup menu then select “coonect to android app” it will open your browser and request to access your google account info

Then come back to android studio and create a project using android studio if you already created the project then select the existing project and select connect

create-firebase-from-android-studio

Then your app will be connected with your firebase account

add-firebase-in-android-app

After connecting your app with firebase you need to add firebase in your android project..

Simply select “Add firebase to android app ” from right menu and a new menu will appear.. select “Accept changes”..

Then android studio will implement firebase dependencies automatically in your android app

Now you can able to send notification using fire base console

For Android studio version less than 2.2:

If you’re using android studio version less then 2.2 then you have to add fire base manually in your application

For this first of all login to your firebase account and go to firebase console .. If you created your project as mentioned in “step 1” then enter that project else follow step 1 and create a project

Then add your android app in your fire base project.. for doing this select “Add Firebase to your Android app ” option and give your apps project code and name and select “ADD APP”

add-firrebase-to-android-app-online

It will return a json file google-services.json .. copy that json file in your Applications “app” folder(by browing in explorer)

Then come back to your android studio and go to the apps build.gradle(Project: app name) file then add

in your dependencies then your code will be looks like

After that go to build.gradle(Module: app) file then add

in dependencies and at the end add

then your code will be looks like

Then sync the gradle file

NB: if you found any error while syncing gradle then update extra field of Android Sdk Manager such as Google play services, google repository etc

Now you’re done with the basic implement of firebase notification implement.. You can now able to send notification from firebase notification console and your app will recieve the notification while in background. Thats all for today.. In next part we will work on own server and  handle the notification.

 

How to add android push notification in android application from android studio – Android developer (part – 2 Working with server)

About Rana

Rana
Love to do fun with programming and build something new.. :)

Check Also

android-push-notification-tutorial

How to add push notification in android application from android studio – Android developer (part – 2 Working with server)

If you followed my old post you have successfully added firebase notification method in your …

Leave a Reply

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