I am developing an app where I am getting FCM notification, in that when the app is open `onMessageRecieved()` method triggers and I am notifying message based on tag and id and deleting notification based on id and tag. But when the app is in background `onMesasageRecived()` is not calling. How to attach id and tag notification or how to delete single notification based on some id when I am getting notification from the background.

> 
> see onMessageReceived
> 
> 
> 

```
 @Override
    public void onMessageReceived(RemoteMessage remoteMessage) {
............
     notificationManager.notify("tag", notificationId, notification);
.......
}

```

> 
> for deleting the message
> 
> 
> 

```
  private void clearNotifications() {

        NotificationManager nMgr = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

        nMgr.cancel("tag",notificationId);
    }

```

> 
> this is working
>  but when the app is closed code is not working.
>  can we notify or attach tag and id from the serverside payload 
> 
> 
>