Intent notification_intent = new Intent(context, Dashboard.class);
notification_intent.putExtra("username", dataSnapshot.getKey()); // sending extra data with the notification, this data can be used when the user clicks on the notification
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notification_intent, 0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
channel = new NotificationChannel("CHANNEL-01", "request", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
notificationBuilder = new NotificationCompat.Builder(context, channel.getId())
.setSmallIcon(R.drawable.account_icon)
.setContentTitle("Notification.")
.setContentText(notification.getUser() + " " + notification.getContent())
.setAutoCancel(true)
.setContentIntent(pendingIntent);
} else
{
notificationBuilder = new NotificationCompat.Builder(context, "CHANNEL-01")
.setSmallIcon(R.drawable.account_icon)
.setContentTitle("Notification.")
.setContentText(notification.getUser() + " " + notification.getContent())
.setAutoCancel(true)
.setContentIntent(pendingIntent);
}
notificationManager.notify(notificationId, notificationBuilder.build());