Like Us on Facebook

Android Firebase Push Notification Tutorial

Hi, in this post we are going to familiar with firebase Push notification .Firebase is a powerful platform for building Android,iOS and web based applications. Before the Google I/O 2016, we used Google Cloud Messaging service (GCM) to send data: notification, messages from the server to the clients or android app users.
Google introduced the firebase cloud messaging in Google I/O 2016 and it makes developers easy and fast to implement in their applications or games.It offers real time data storage and, user authentication, analytics, hosting, database,  notification, cloud messaging and more .Firebase is new and not the part of Google Cloud Platform.

Read more
How to create Chat Application Using Firebase
How to create Push notification in Android Studio
Android Registration and Login with PHP and MYSQL

Prerequisites:
  • JDK 7.0 or Above
  • Android Studio 2.0

Steps to Follow:

Step 1: Create a New Android Studio project name FireBasepush.

Step 2: Select minimum API level 14  so that it can support maximum of Android Device available in the google play.

Step 3: Select  Blank  Activity and Give your layout xml name is activity_main and click finish.

Step 4: Go to Google FireBase Developer console and Create a new Project .Add your application name MyPush Appin project name and select your country(I have selected India) and click Create Project button

Create Project

Step 5. After creating new project in firebase, you will see in the screen like below.

Creating new project in firebase

Step 6. Click on the add firebase to your android app. Here you will  provide your application package name. After adding package name in the box click Add App button.

A file google-services.jsonwill be downloaded. Click continue and then finish button.

Step 7. In android studio, Switch to the project view in Android Studio, you will see project root directory. Add google-services.json file that you downloaded to your android app directory like the screenshot below.

Google Services

Step 8. Open the project level build.gradle file and addthe  classpath 'com.google.gms:google-services:3.0.0' as dependencies like below.
 
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
jcenter()
    }
    dependencies {
classpath'com.android.tools.build:gradle:2.0.0'
classpath'com.google.gms:google-services:3.0.0'


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

}
}

allprojects {
    repositories {
jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
 
Step 9. Now open app level build.gradle file and add apply plugin: 'com.google.gms.googleservices' and compile com.google.firebase:firebase-messaging:9.0.2' as dependencies.
Then Sync your Project.
 
apply plugin: 'com.android.application'
android {

compileSdkVersion23
buildToolsVersion"24.0.1" defaultConfig {
applicationId"com.example.prosen.firebasepush"
minSdkVersion14
targetSdkVersion23
versionCode1
versionName"1.0"
}

buildTypes {
        release {
minifyEnabledfalse
proguardFilesgetDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
    }
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
apply plugin: 'com.google.gms.google-services'
compile 'com.google.firebase:firebase-messaging:9.0.2'
}
 
Step 10. Add the internet Permission in manifest file
 
<uses-permissionandroid:name="android.permission.INTERNET" />

Step 11. Now go to FireBase Console.Choose your project that we recently created.
Click Notification from left menu.
 
FireBase Console
 
Step 12. Click send your first message.

Type your message in enter message area, enter message label, choose your app and click Send Message button. Review your message and click Send button.

Message button
 
 Don’t open your application during  sendingmessage. After sending notification to your android application open FireBasepush App. Notification looks like below screenshot.

FireBase Push App
 
 

Posted By UandBlog

UandBlog is a Global Leading source of Finance, Health, Lifestyle, Technology, Gaming and Programing and other information, it is a fastest growing blog for all , for latest post or information like us on facebook , follow on Twitter, Google+ and Pinterest.

Comments ( 1 )

vikash sharma:
Sir i liked your videos , and i need immediate contact with you, please provide your mail adddress.
Admin:
loginprosenjit@gmail.com

    Leave a comment..

    Click to login.

    Subscribe Latest Information

    Most Popular Posts