I am struggling with FCM notifications on Android. The issue is only when the app is closed and not running. I am trying to achieve no click activity I don\'t want the app
The notification is getting disappeared when you click on it because you did not add any action when onClick is performed.
To give onClick functionality on notification, you have to use PendingIntent with the target activity. You can also add additional data into it if needed.
Before initializing notificationManager, add this code:
Intent openIntent = new Intent(mContext, TargetActivity.class);
// Falg to clear the stack.
openIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0,
openIntent, 0);
notificationBuilder.setContentIntent(pendingIntent);