'Android notifications not prompting on device, they show in silent section, (using FCM)

I receive push notifications on my android app, but they are always in the silent section and when I am in a different app and a notifications comes through it does not show up like this

enter image description here

Only if i scroll from the top and look in the notifications section I find it in the silent section like this

enter image description here

From code perspective, not exactly sure what code should I share as I have no idea where I need to actually look through

I have implemented custom notifications to show up like this, the above issue of not showing notifications like popping up happens with normal notifications for my app and also custom notifications which I implemented.

private fun showCustomPushNotification(message: RemoteMessage, chargerId: String) {
    if(!isAppOnForeground()) {
        val notificationLayout = RemoteViews(
            packageName,
            R.layout.plugin_requires_approval_notification_small
        )
        val notificationLayoutExpanded = RemoteViews(
            packageName,
            R.layout.plugin_requires_approval_notification_large
        )

        val title = message.data[MSG_TITLE]
        val subTitle = message.data[MSG_SUB_TITLE]

        notificationLayout.setTextViewText(R.id.tvTitle, title)
        notificationLayout.setTextViewText(R.id.tvSubTitle, subTitle)

        notificationLayoutExpanded.setTextViewText(R.id.tvTitle, title)
        notificationLayoutExpanded.setTextViewText(R.id.tvSubTitle, subTitle)

        val intent = Intent(this, MainActivity::class.java).apply {
            flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
        }

        val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_IMMUTABLE)

        val customNotification = NotificationCompat.Builder(
            this,
            CarInfoProcessingService.NOTIFICATION_CHANNEL_ID
        )
            .setSmallIcon(R.mipmap.ic_launcher)
            .setStyle(NotificationCompat.DecoratedCustomViewStyle())
            .setCustomContentView(notificationLayout)
            .setCustomBigContentView(notificationLayoutExpanded)
            .setContentIntent(pendingIntent)
            .setAutoCancel(true)
            .setPriority(NotificationCompat.PRIORITY_HIGH)
            .build()

        val approveIntent = Intent(this, CustomNotificationListener::class.java)
        approveIntent.putExtra("onClickListener", "approve")
        approveIntent.putExtra("chargerId", chargerId)
        val pendingApproveIntent = PendingIntent.getBroadcast(
            this,
            0,
            approveIntent,
            PendingIntent.FLAG_UPDATE_CURRENT
        )
        notificationLayoutExpanded.setOnClickPendingIntent(R.id.btnApprove, pendingApproveIntent)

        val denyIntent = Intent(this, CustomNotificationListener::class.java)
        denyIntent.putExtra("onClickListener", "deny")
        denyIntent.putExtra("chargerId", chargerId)
        val pendingDenyIntent = PendingIntent.getBroadcast(
            this,
            1,
            denyIntent,
            PendingIntent.FLAG_UPDATE_CURRENT
        )

        notificationLayoutExpanded.setOnClickPendingIntent(R.id.btnDeny, pendingDenyIntent)

        val notificationManager =
            getSystemService(NOTIFICATION_SERVICE) as NotificationManager
        notificationManager.notify(CustomNotificationListener.WHAT_NOTIFICATION_ID, customNotification)
    }
}

Could you please suggest where I can look please I am a bit clueless. looked online but was not able to find it.

Thank you in advance R



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source