title: How to do some logic when clicking push notification
body: <p>My app receives FCM notification when the admin activate the user account from control panel, I want to to do some action from a method like a toast or deleting some data from my db when the user clicks the push notification.!</p>
  
  <p>Is this possible? </p>
  
  <p>here's the code inside <code>FirebaseMessagingService</code> class</p>
  
  <pre><code>public class CustomFirebaseMessagingService extends FirebaseMessagingService {
  
    public static String INTENT_FILTER = "INTENT_FILTER";
  
    @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
  
      try {
  
        if (remoteMessage.getNotification() != null) {
  
          Intent intent = new Intent(INTENT_FILTER);
          sendNotification(remoteMessage.getNotification().getBody(), intent);
          sendBroadcast(intent);
        }
      } catch (Exception ex) {
      }
      }
  
  
      private void sendNotification(String messageBody, Intent intent) {
  
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
          PendingIntent.FLAG_ONE_SHOT);
  
      Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
  
      NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
          .setSmallIcon(R.drawable.logo)
          .setContentTitle("UPDATE")
          .setContentText(messageBody)
          .setAutoCancel(true)
          .setSound(defaultSoundUri)
          .setContentIntent(pendingIntent);
  
      NotificationManager notificationManager =
          (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
      notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
    }
  }
  </code></pre>