I encountered an issue sending notifications in my Android app. I am setting my custom icon via .setSmallIcon(R.drawable.ic_bublic_2) but android ignores it and shows a default launcher icon instead. Here is my code:
private fun publishNotification(title: String, body: String) {
val intent=Intent(this, MainActivity::class.java)
val pendingIntent = TaskStackBuilder.create(this).run {
addNextIntentWithParentStack(intent)
getPendingIntent(0, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
}
val notif = NotificationCompat.Builder(this,CHANNEL_ID)
.setContentTitle(title)
.setContentText(body)
.setSmallIcon(R.drawable.ic_bublic_2)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setContentIntent(pendingIntent)
.build()
val notifManger = NotificationManagerCompat.from(this)
if (ActivityCompat.checkSelfPermission(
this,
Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED
) {
notifManger.notify(DEFAULT_NOTIF_ID, notif)
}
}
and here is a screenshot to be more clear:

Edit 1:
setting .setLargeIcon(largeIconBitmap) solve problem for icon on notification but the status bar icon remains the same launcher icon.

