The next step is to Add the SDK to integrate the Firebase libraries in the project.

Add the SDK

To integrate the Firebase libraries into one of your own projects, you need to perform a few basic tasks to prepare your Android Studio project. You may have already done this as part of adding Firebase to your app.

Add rules to your root-level build.gradle file, to include the google-services plugin:

Enter this information in the firebase console and add the app to firebase project. Once you click on add app button, your browser would automatically download a JSON file named "google-services.json".

Now copy the google-services.json file you have just downloaded into your Android app module root directory.

Follow the instructions given on the firebase console as you proceed ahead.
a. Add following code line to your project level build.gradle

dependencies{ classpath 'com.google.gms:google-services:3.1.0' .....

b. Add following code line at the end of your app level build.gradle.

//following are the dependencies to be added
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile 'com.android.support:multidex:1.0.1'
}
// this line goes to the end of the file
apply plugin: 'com.google.gms.google-services'

c. Android studio would ask you to sync project. Click on Sync now.

Next task is to add two services.
a. One extending FirebaseMessagingService with intent-filter as following

Once we have the access token, we can use firebase console to send out the notification. Run the app on your android handset.

Click on Notification in Firebase console and UI will help you to send out your first message. Firebase offers functionality to send messages to single device(By using the device token id we captured) or all the users using our app or to specific group of users. Once you send your first message, your mobile screen should look like following.

To retrieve the current registration token extend the FirebaseInstanceIdService class and override the onTokenRefresh() method:

public class MyInstanceIdListenerService extends FirebaseInstanceIdService {
// Called if InstanceID token is updated. Occurs if the security of the previous token had been
// compromised. This call is initiated by the InstanceID provider.
@Override
public void onTokenRefresh() {
// Get updated InstanceID token.
String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// Send this token to your server or store it locally
}
}

To receive messages, use a service that extends FirebaseMessagingService and override the onMessageReceived method.

in Firebase can grouped user by their behavior like "AppVersion,free user,purchase user,or any specific rules" and then send notification to specific group by send Topic Feature in fireBase.
to register user in topic use

We will put data to this location from our Android device. You don't have to create the database structure (tabs, fields... etc), it will be automatically created when you'll send Java object to Firebase!

Create a Java object that contains all the attributes you want to send to the database:

By default, Firebase Storage rules applies Authentication restriction. If user is authenticated, only then, he can perform operations on Firebase Storage, else he cannot. I have disabled the authentication part in this demo by updating Storage rules. Previously, rules were looking like: