diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt index d014b29db..698db258a 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PinpointNotificationPayload.kt @@ -24,6 +24,7 @@ class PinpointNotificationPayload internal constructor( val title: String? = null, val body: String? = null, val imageUrl: String? = null, + val largeImageUrl: String? = null, val action: Map = mapOf(), val silentPush: Boolean = false, channelId: String? = null, @@ -45,6 +46,8 @@ class PinpointNotificationPayload internal constructor( ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_BODY] val imageUrl = data[PushNotificationsConstants.IMAGEURL] ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_IMAGEURL] + val largeImageUrl = data[PushNotificationsConstants.LARGEIMAGEURL] + ?: data[PushNotificationsConstants.PINPOINT_NOTIFICATION_LARGEIMAGEURL] val channelId = payload.channelId ?: PushNotificationsConstants.DEFAULT_NOTIFICATION_CHANNEL_ID val silentPush = data[PushNotificationsConstants.PINPOINT_NOTIFICATION_SILENTPUSH].equals("1") val action: MutableMap = mutableMapOf() @@ -62,7 +65,7 @@ class PinpointNotificationPayload internal constructor( } return PinpointNotificationPayload( - title, body, imageUrl, + title, body, imageUrl, largeImageUrl, action, silentPush, channelId, payload.targetClass, payload.contentProvider ) diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt index 66ec9cc46..2ebb849d8 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsConstants.kt @@ -29,6 +29,7 @@ class PushNotificationsConstants { const val TITLE = "title" // title const val MESSAGE = "message" // message const val IMAGEURL = "imageUrl" // imageUrl + const val LARGEIMAGEURL = "largeImageUrl" // largeImageUrl const val JOURNEY = "journey" // journey const val JOURNEY_ID = "journey_id" // journey_id const val JOURNEY_ACTIVITY_ID = "journey_activity_id" // journey_activity_id @@ -38,6 +39,7 @@ class PushNotificationsConstants { const val PINPOINT_NOTIFICATION_TITLE = "$NOTIFICATION_PREFIX$TITLE" // pinpoint.notification.title const val PINPOINT_NOTIFICATION_BODY = "${NOTIFICATION_PREFIX}body" // pinpoint.notification.body const val PINPOINT_NOTIFICATION_IMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.imageUrl + const val PINPOINT_NOTIFICATION_LARGEIMAGEURL = "$NOTIFICATION_PREFIX$IMAGEURL" // pinpoint.notification.largeImageUrl // pinpoint.notification.silentPush const val PINPOINT_NOTIFICATION_SILENTPUSH = "${NOTIFICATION_PREFIX}silentPush" const val CAMPAIGN_ID = "campaign_id" // campaign_id diff --git a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt index f58c18836..0c89212ce 100644 --- a/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt +++ b/aws-push-notifications-pinpoint-common/src/main/java/com/amplifyframework/pushnotifications/pinpoint/PushNotificationsUtils.kt @@ -25,11 +25,13 @@ import android.content.Context import android.content.Intent import android.graphics.Bitmap import android.graphics.BitmapFactory +import android.graphics.drawable.Icon import android.os.Build import androidx.annotation.ChecksSdkIntAtLeast import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.IconCompat import com.amplifyframework.pushnotifications.pinpoint.common.R import java.net.URL import kotlinx.coroutines.CoroutineScope @@ -110,7 +112,8 @@ class PushNotificationsUtils( targetClass: Class<*>? ) { CoroutineScope(Dispatchers.IO).launch { - val largeImageIcon = payload.imageUrl?.let { downloadImage(it) } + val imageIcon = payload.imageUrl?.let { downloadImage(it) } + val largeImageIcon = payload.largeImageUrl?.let { downloadImage(it) } val notificationIntent = Intent(context, payload.targetClass ?: targetClass) notificationIntent.putExtra("amplifyNotificationPayload", payload) notificationIntent.putExtra("notificationId", notificationId) @@ -130,7 +133,7 @@ class PushNotificationsUtils( builder.apply { setContentTitle(payload.title) setContentText(payload.body) - setSmallIcon(R.drawable.ic_launcher_foreground) + setSmallIcon(IconCompat.createWithBitmap(imageIcon)) setContentIntent(pendingIntent) setPriority(NotificationCompat.PRIORITY_DEFAULT) setLargeIcon(largeImageIcon)