I have created an app server, using this server I send a notification to my app.app receives a notification but the problem is a notification the app received comes from a script which I wrote on the server side. The code which is written on MyFirebaseMessagingService extends FirebaseMessagingService does not get executed.

    public class MyFirebaseMessagingService extends     
   FirebaseMessagingService {
    public MyFirebaseMessagingService() {

    }
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
        //super.onMessageReceived(remoteMessage);

        Log.i("Remote Message", remoteMessage.getNotification().getBody().toString());
        sendNotification(remoteMessage.getNotification().getBody());
    }

    private void sendNotification(String remoteMessage) {

        Log.i("AAAAAAAAAAAA","AAAAAAAAAAA");
        Intent i = new Intent(this, Tips_Notification.class);
        //i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
        // Adds the back stack for the Intent (but not the Intent 
    itself)
        stackBuilder.addParentStack(Tips_Notification.class);
        // Adds the Intent that starts the Activity to the top of the 
     stack
        stackBuilder.addNextIntent(i);
        PendingIntent pi = stackBuilder.getPendingIntent( 0, 
    PendingIntent.FLAG_UPDATE_CURRENT
                | PendingIntent.FLAG_ONE_SHOT);
        Uri defaultSoundUri = 
    RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new 
    NotificationCompat.Builder(this);
        //notificationBuilder.setSmallIcon(R.drawable.ic_stat_name);
        notificationBuilder.setContentTitle("Abhishek ghatge");
        notificationBuilder.setContentText("Alert Trade School 
    notification");notificationBuilder.setAutoCancel(false);
        notificationBuilder.setSound(defaultSoundUri);
        notificationBuilder.setContentIntent(pi);





 notificationBuilder.setDefaults(Notification.DEFAULT_SOUND|Notification. 
    DEFAULT_LIGHTS|Notification.DEFAULT_VIBRATE);

        NotificationManager notificationManager = (NotificationManager) 
   getSystemService(Context.NOTIFICATION_SERVICE);
         notificationManager.notify(0,notificationBuilder.build());

    }
  }


    <?php
    include '../config/connection.php';
    include '../push_notification/push.php';
    include '../push_notification/firebase.php';

   echo $string = $_POST['message'];

   /* 

   $firebase = new Firebase();
   $push = new Push();
   $push->setTitle("Trade School");
    $push->setMessage($string);
  //$push->setPayload($payload);
  $json = $push->getPush();

   */

The Notification Comes Using Above Code. I remove the NotificationCompat code from MyFirebaseMessagingService Class but still, the app gets a notification.

 I want a pop-up notification like Whatsapp shows.

0 Answers