Skip to content

Commit

Permalink
fix: image not shown when image url in notification payload (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahroz16 committed Feb 17, 2023
1 parent 5a99392 commit 0abdc85
Showing 1 changed file with 4 additions and 6 deletions.
Expand Up @@ -168,13 +168,11 @@ internal class CustomerIOPushNotificationHandler(
.setStyle(NotificationCompat.BigTextStyle().bigText(body))
tintColor?.let { color -> notificationBuilder.setColor(color) }

// This is custom logic to add images to a push notification. Some image URLs have not
// been able to display an image in a push. https://github.com/customerio/issues/issues/7293
// Instead, we recommend customers use `notification.image` in the FCM payload to bypass
// our logic and use the logic from FCM's SDK for image handling instead.
try {
// check for image
val notificationImage = bundle.getString(IMAGE_KEY)
// check for image in data and notification payload to cater for both simple and rich push
// data only payload (foreground and background)
// notification + data payload (foreground)
val notificationImage = bundle.getString(IMAGE_KEY) ?: remoteMessage.notification?.imageUrl?.toString()
if (notificationImage != null) {
addImage(notificationImage, notificationBuilder, body)
}
Expand Down

0 comments on commit 0abdc85

Please sign in to comment.