I am using the following code with the notification where the images are from the drawable. But, I want to use the image URL to use the images that I have in my Firebase Storage. How can I do that. I tried adding the URL and that gives me an error.
val bitmap = BitmapFactory.decodeResource(applicationContext.resources,R.drawable.product_image)
val bitmapLargeIcon = BitmapFactory.decodeResource(applicationContext.resources,R.drawable.comp_logo)
This is the complete code.
private fun sendNotification(title: String, message: String) {
val intent: Intent = Intent(this, SplashActivity::class.java).apply {
flags=Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
}
val pendingIntent: PendingIntent = PendingIntent.getActivity(this, 0,intent, 0)
val bitmap = BitmapFactory.decodeResource(applicationContext.resources,R.drawable.product_image)
val bitmapLargeIcon = BitmapFactory.decodeResource(applicationContext.resources,R.drawable.comp_logo)
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.drawable.product_image)
.setContentTitle(title)
.setContentText(message)
.setLargeIcon(bitmapLargeIcon)
.setStyle(NotificationCompat.BigPictureStyle().bigPicture(bitmap))
.setContentIntent(pendingIntent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
with(NotificationManagerCompat.from(this)) {
notify(notificationId, builder.build())
}
}