0 0 0 0


I don't know anything about push notification. i am trying to learn. but i cannot understand. I have one table mysql database in server system.if any changes are made in the table means i want display as notification into the android mobile please give me the suggestions to me

Best Answer:

actually now recently mostly use for push notification FCM inside that u project .... best link for build the push notication: link

steps for perform push notification - Firebase Cloud Messaging Tutorial for Android

  • Go to firebase console and create a new project.
  • Now put your app name and select your country.
  • Now click on Add Firebase to Your Android App.
  • Now you have to enter your projects package name and click on ADD APP.
  • After clicking add app you will get google-services.json file.
  • On App side

  • Now come back to your android project. Go to app folder and paste google-services.json file
  • Now go to your root level build.gradle file and add the following code.

    a. Add this line classpath ''

    b. Add this line compile ''

  • Now sync your project.

  • Create a class named and write the following code:

    public class MyFirebaseInstanceIDService extends FirebaseInstanceIdService {
        private static final String TAG = "MyFirebaseIIDService";
        public void onTokenRefresh() {
            //Getting registration token
            String refreshedToken = FirebaseInstanceId.getInstance().getToken();
            //Displaying token on logcat 
            Log.d(TAG, "Refreshed token: " + refreshedToken);
        private void sendRegistrationToServer(String token) {
            //You can implement this method to store the token on your server 
            //Not required for current project 
  • Now create and write the following code:

    import android.content.Context;
    import android.content.Intent;
    import android.util.Log;
    public class MyFirebaseMessagingService extends FirebaseMessagingService {
        private static final String TAG = "MyFirebaseMsgService";
        public void onMessageReceived(RemoteMessage remoteMessage) {
            //Displaying data in log
            //It is optional 
            Log.d(TAG, "From: " + remoteMessage.getFrom());
            Log.d(TAG, "Notification Message Body: " + remoteMessage.getNotification().getBody());
            //Calling method to generate notification
        //This method is only generating push notification
        //It is same as we did in earlier posts 
        private void sendNotification(String messageBody) {
            Intent intent = new Intent(this, MainActivity.class);
            PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
            Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                    .setContentTitle("Firebase Push Notification")
            NotificationManager notificationManager =
                    (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  • Now we have to define the above services in our AndroidManifest.xml file. So go to manifest and modify as follows.

    <!-- Adding Internet Permission -->
    <uses-permission android:name="android.permission.INTERNET"/>
        <activity android:name=".MainActivity">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            Defining Services
                <action android:name=""/>
                <action android:name=""/>

  • finally

    Go to firebase console and select the app you created. From the left menu select notification. Click on new message. Enter message, select single device and paste the token you copied and click on send. The same as I did on the video, and check your device

    Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs